pi2dsh 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +122 -0
- package/README.zh.md +122 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.mjs +128 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/compat/pi-ai.d.mts +2597 -0
- package/dist/compat/pi-ai.d.mts.map +1 -0
- package/dist/compat/pi-ai.mjs +4669 -0
- package/dist/compat/pi-ai.mjs.map +1 -0
- package/dist/compat/pi-coding-agent.d.mts +745 -0
- package/dist/compat/pi-coding-agent.d.mts.map +1 -0
- package/dist/compat/pi-coding-agent.mjs +4 -0
- package/dist/compat/pi-tui.d.mts +3 -0
- package/dist/compat/pi-tui.mjs +3622 -0
- package/dist/compat/pi-tui.mjs.map +1 -0
- package/dist/host.d.mts +35 -0
- package/dist/host.d.mts.map +1 -0
- package/dist/host.mjs +197 -0
- package/dist/host.mjs.map +1 -0
- package/dist/index.d.mts +69 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +5 -0
- package/dist/mcp-config-jL9w70It.mjs +1535 -0
- package/dist/mcp-config-jL9w70It.mjs.map +1 -0
- package/dist/pi-coding-agent-Dsg6_0ua.mjs +2060 -0
- package/dist/pi-coding-agent-Dsg6_0ua.mjs.map +1 -0
- package/dist/pi-config-shim-CZ1wFzqM.mjs +27 -0
- package/dist/pi-config-shim-CZ1wFzqM.mjs.map +1 -0
- package/dist/pi-tui-iHoF2tFc.d.mts +1043 -0
- package/dist/pi-tui-iHoF2tFc.d.mts.map +1 -0
- package/dist/pi-tui-utils-CcaVtm-3.mjs +895 -0
- package/dist/pi-tui-utils-CcaVtm-3.mjs.map +1 -0
- package/dist/pi-types-KazmR2O5.d.mts +62 -0
- package/dist/pi-types-KazmR2O5.d.mts.map +1 -0
- package/dist/pi-uuid-Db8ShZsK.mjs +47 -0
- package/dist/pi-uuid-Db8ShZsK.mjs.map +1 -0
- package/dist/rolldown-runtime-C2Q2p085.mjs +15 -0
- package/dist/runtime-D84Hv_3m.mjs +1499 -0
- package/dist/runtime-D84Hv_3m.mjs.map +1 -0
- package/dist/runtime.d.mts +31 -0
- package/dist/runtime.d.mts.map +1 -0
- package/dist/runtime.mjs +3 -0
- package/dist/source-D7Ir-rPT.mjs +154 -0
- package/dist/source-D7Ir-rPT.mjs.map +1 -0
- package/dist/types-7IWJPPvS.d.mts +59 -0
- package/dist/types-7IWJPPvS.d.mts.map +1 -0
- package/package.json +135 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi-tui.mjs","names":["functionKey","join","homedir","dirname","basename"],"sources":["../../src/compat/vendor/pi-tui-fuzzy.ts","../../src/compat/vendor/pi-tui-keys.ts","../../src/compat/vendor/pi-tui-terminal-colors.ts","../../src/compat/vendor/pi-tui-keybindings.ts","../../src/compat/vendor/pi-tui-latex.ts","../../src/compat/vendor/pi-tui-terminal-image.ts","../../src/compat/vendor/pi-tui-autocomplete.ts","../../src/compat/pi-tui.ts"],"sourcesContent":["// @ts-nocheck — vendored Pi source; checked upstream under Pi's own tsconfig.\n/**\n * Fuzzy matching utilities.\n * Matches if all query characters appear in order (not necessarily consecutive).\n * Lower score = better match.\n */\n\nexport interface FuzzyMatch {\n\tmatches: boolean;\n\tscore: number;\n}\n\nexport function fuzzyMatch(query: string, text: string): FuzzyMatch {\n\tconst queryLower = query.toLowerCase();\n\tconst textLower = text.toLowerCase();\n\n\tconst matchQuery = (normalizedQuery: string): FuzzyMatch => {\n\t\tif (normalizedQuery.length === 0) {\n\t\t\treturn { matches: true, score: 0 };\n\t\t}\n\n\t\tif (normalizedQuery.length > textLower.length) {\n\t\t\treturn { matches: false, score: 0 };\n\t\t}\n\n\t\tlet queryIndex = 0;\n\t\tlet score = 0;\n\t\tlet lastMatchIndex = -1;\n\t\tlet consecutiveMatches = 0;\n\n\t\tfor (let i = 0; i < textLower.length && queryIndex < normalizedQuery.length; i++) {\n\t\t\tif (textLower[i] === normalizedQuery[queryIndex]) {\n\t\t\t\tconst isWordBoundary = i === 0 || /[\\s\\-_./:]/.test(textLower[i - 1]!);\n\n\t\t\t\t// Reward consecutive matches\n\t\t\t\tif (lastMatchIndex === i - 1) {\n\t\t\t\t\tconsecutiveMatches++;\n\t\t\t\t\tscore -= consecutiveMatches * 5;\n\t\t\t\t} else {\n\t\t\t\t\tconsecutiveMatches = 0;\n\t\t\t\t\t// Penalize gaps\n\t\t\t\t\tif (lastMatchIndex >= 0) {\n\t\t\t\t\t\tscore += (i - lastMatchIndex - 1) * 2;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Reward word boundary matches\n\t\t\t\tif (isWordBoundary) {\n\t\t\t\t\tscore -= 10;\n\t\t\t\t}\n\n\t\t\t\t// Slight penalty for later matches\n\t\t\t\tscore += i * 0.1;\n\n\t\t\t\tlastMatchIndex = i;\n\t\t\t\tqueryIndex++;\n\t\t\t}\n\t\t}\n\n\t\tif (queryIndex < normalizedQuery.length) {\n\t\t\treturn { matches: false, score: 0 };\n\t\t}\n\n\t\tif (normalizedQuery === textLower) {\n\t\t\tscore -= 100;\n\t\t}\n\n\t\treturn { matches: true, score };\n\t};\n\n\tconst primaryMatch = matchQuery(queryLower);\n\tif (primaryMatch.matches) {\n\t\treturn primaryMatch;\n\t}\n\n\tconst alphaNumericMatch = queryLower.match(/^(?<letters>[a-z]+)(?<digits>[0-9]+)$/);\n\tconst numericAlphaMatch = queryLower.match(/^(?<digits>[0-9]+)(?<letters>[a-z]+)$/);\n\tconst swappedQuery = alphaNumericMatch\n\t\t? `${alphaNumericMatch.groups?.digits ?? \"\"}${alphaNumericMatch.groups?.letters ?? \"\"}`\n\t\t: numericAlphaMatch\n\t\t\t? `${numericAlphaMatch.groups?.letters ?? \"\"}${numericAlphaMatch.groups?.digits ?? \"\"}`\n\t\t\t: \"\";\n\n\tif (!swappedQuery) {\n\t\treturn primaryMatch;\n\t}\n\n\tconst swappedMatch = matchQuery(swappedQuery);\n\tif (!swappedMatch.matches) {\n\t\treturn primaryMatch;\n\t}\n\n\treturn { matches: true, score: swappedMatch.score + 5 };\n}\n\n/**\n * Filter and sort items by fuzzy match quality (best matches first).\n * Supports whitespace- and slash-separated tokens: all tokens must match.\n */\nexport function fuzzyFilter<T>(items: T[], query: string, getText: (item: T) => string): T[] {\n\tif (!query.trim()) {\n\t\treturn items;\n\t}\n\n\tconst tokens = query\n\t\t.trim()\n\t\t.split(/[\\s/]+/)\n\t\t.filter((t) => t.length > 0);\n\n\tif (tokens.length === 0) {\n\t\treturn items;\n\t}\n\n\tconst results: { item: T; totalScore: number }[] = [];\n\n\tfor (const item of items) {\n\t\tconst text = getText(item);\n\t\tlet totalScore = 0;\n\t\tlet allMatch = true;\n\n\t\tfor (const token of tokens) {\n\t\t\tconst match = fuzzyMatch(token, text);\n\t\t\tif (match.matches) {\n\t\t\t\ttotalScore += match.score;\n\t\t\t} else {\n\t\t\t\tallMatch = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (allMatch) {\n\t\t\tresults.push({ item, totalScore });\n\t\t}\n\t}\n\n\tresults.sort((a, b) => a.totalScore - b.totalScore);\n\treturn results.map((r) => r.item);\n}\n","// @ts-nocheck — vendored Pi source; checked upstream under Pi's own tsconfig.\n/**\n * Keyboard input handling for terminal applications.\n *\n * Supports both legacy terminal sequences and Kitty keyboard protocol.\n * See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/\n * Reference: https://github.com/sst/opentui/blob/7da92b4088aebfe27b9f691c04163a48821e49fd/packages/core/src/lib/parse.keypress.ts\n *\n * Symbol keys are also supported, however some ctrl+symbol combos\n * overlap with ASCII codes, e.g. ctrl+[ = ESC.\n * See: https://sw.kovidgoyal.net/kitty/keyboard-protocol/#legacy-ctrl-mapping-of-ascii-keys\n * Those can still be * used for ctrl+shift combos\n *\n * API:\n * - matchesKey(data, keyId) - Check if input matches a key identifier\n * - parseKey(data) - Parse input and return the key identifier\n * - Key - Helper object for creating typed key identifiers\n * - setKittyProtocolActive(active) - Set global Kitty protocol state\n * - isKittyProtocolActive() - Query global Kitty protocol state\n */\n\n// =============================================================================\n// Global Kitty Protocol State\n// =============================================================================\n\nlet _kittyProtocolActive = false;\n\n/**\n * Set the global Kitty keyboard protocol state.\n * Called by ProcessTerminal after detecting protocol support.\n */\nexport function setKittyProtocolActive(active: boolean): void {\n\t_kittyProtocolActive = active;\n}\n\n/**\n * Query whether Kitty keyboard protocol is currently active.\n */\nexport function isKittyProtocolActive(): boolean {\n\treturn _kittyProtocolActive;\n}\n\n// =============================================================================\n// Type-Safe Key Identifiers\n// =============================================================================\n\ntype Letter =\n\t| \"a\"\n\t| \"b\"\n\t| \"c\"\n\t| \"d\"\n\t| \"e\"\n\t| \"f\"\n\t| \"g\"\n\t| \"h\"\n\t| \"i\"\n\t| \"j\"\n\t| \"k\"\n\t| \"l\"\n\t| \"m\"\n\t| \"n\"\n\t| \"o\"\n\t| \"p\"\n\t| \"q\"\n\t| \"r\"\n\t| \"s\"\n\t| \"t\"\n\t| \"u\"\n\t| \"v\"\n\t| \"w\"\n\t| \"x\"\n\t| \"y\"\n\t| \"z\";\n\ntype Digit = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\";\n\ntype SymbolKey =\n\t| \"`\"\n\t| \"-\"\n\t| \"=\"\n\t| \"[\"\n\t| \"]\"\n\t| \"\\\\\"\n\t| \";\"\n\t| \"'\"\n\t| \",\"\n\t| \".\"\n\t| \"/\"\n\t| \"!\"\n\t| \"@\"\n\t| \"#\"\n\t| \"$\"\n\t| \"%\"\n\t| \"^\"\n\t| \"&\"\n\t| \"*\"\n\t| \"(\"\n\t| \")\"\n\t| \"_\"\n\t| \"+\"\n\t| \"|\"\n\t| \"~\"\n\t| \"{\"\n\t| \"}\"\n\t| \":\"\n\t| \"<\"\n\t| \">\"\n\t| \"?\";\n\ntype SpecialKey =\n\t| \"escape\"\n\t| \"esc\"\n\t| \"enter\"\n\t| \"return\"\n\t| \"tab\"\n\t| \"space\"\n\t| \"backspace\"\n\t| \"delete\"\n\t| \"insert\"\n\t| \"clear\"\n\t| \"home\"\n\t| \"end\"\n\t| \"pageUp\"\n\t| \"pageDown\"\n\t| \"up\"\n\t| \"down\"\n\t| \"left\"\n\t| \"right\"\n\t| \"f1\"\n\t| \"f2\"\n\t| \"f3\"\n\t| \"f4\"\n\t| \"f5\"\n\t| \"f6\"\n\t| \"f7\"\n\t| \"f8\"\n\t| \"f9\"\n\t| \"f10\"\n\t| \"f11\"\n\t| \"f12\";\n\ntype BaseKey = Letter | Digit | SymbolKey | SpecialKey;\ntype ModifierName = \"ctrl\" | \"shift\" | \"alt\" | \"super\";\n\ntype ModifiedKeyId<Key extends string, RemainingModifiers extends ModifierName = ModifierName> = {\n\t[M in RemainingModifiers]: `${M}+${Key}` | `${M}+${ModifiedKeyId<Key, Exclude<RemainingModifiers, M>>}`;\n}[RemainingModifiers];\n\n/**\n * Union type of all valid key identifiers.\n * Provides autocomplete and catches typos at compile time.\n */\nexport type KeyId = BaseKey | ModifiedKeyId<BaseKey>;\n\n/**\n * Helper object for creating typed key identifiers with autocomplete.\n *\n * Usage:\n * - Key.escape, Key.enter, Key.tab, etc. for special keys\n * - Key.backtick, Key.comma, Key.period, etc. for symbol keys\n * - Key.ctrl(\"c\"), Key.alt(\"x\"), Key.super(\"k\") for single modifiers\n * - Key.ctrlShift(\"p\"), Key.ctrlAlt(\"x\"), Key.ctrlSuper(\"k\") for combined modifiers\n */\nexport const Key = {\n\t// Special keys\n\tescape: \"escape\" as const,\n\tesc: \"esc\" as const,\n\tenter: \"enter\" as const,\n\treturn: \"return\" as const,\n\ttab: \"tab\" as const,\n\tspace: \"space\" as const,\n\tbackspace: \"backspace\" as const,\n\tdelete: \"delete\" as const,\n\tinsert: \"insert\" as const,\n\tclear: \"clear\" as const,\n\thome: \"home\" as const,\n\tend: \"end\" as const,\n\tpageUp: \"pageUp\" as const,\n\tpageDown: \"pageDown\" as const,\n\tup: \"up\" as const,\n\tdown: \"down\" as const,\n\tleft: \"left\" as const,\n\tright: \"right\" as const,\n\tf1: \"f1\" as const,\n\tf2: \"f2\" as const,\n\tf3: \"f3\" as const,\n\tf4: \"f4\" as const,\n\tf5: \"f5\" as const,\n\tf6: \"f6\" as const,\n\tf7: \"f7\" as const,\n\tf8: \"f8\" as const,\n\tf9: \"f9\" as const,\n\tf10: \"f10\" as const,\n\tf11: \"f11\" as const,\n\tf12: \"f12\" as const,\n\n\t// Symbol keys\n\tbacktick: \"`\" as const,\n\thyphen: \"-\" as const,\n\tequals: \"=\" as const,\n\tleftbracket: \"[\" as const,\n\trightbracket: \"]\" as const,\n\tbackslash: \"\\\\\" as const,\n\tsemicolon: \";\" as const,\n\tquote: \"'\" as const,\n\tcomma: \",\" as const,\n\tperiod: \".\" as const,\n\tslash: \"/\" as const,\n\texclamation: \"!\" as const,\n\tat: \"@\" as const,\n\thash: \"#\" as const,\n\tdollar: \"$\" as const,\n\tpercent: \"%\" as const,\n\tcaret: \"^\" as const,\n\tampersand: \"&\" as const,\n\tasterisk: \"*\" as const,\n\tleftparen: \"(\" as const,\n\trightparen: \")\" as const,\n\tunderscore: \"_\" as const,\n\tplus: \"+\" as const,\n\tpipe: \"|\" as const,\n\ttilde: \"~\" as const,\n\tleftbrace: \"{\" as const,\n\trightbrace: \"}\" as const,\n\tcolon: \":\" as const,\n\tlessthan: \"<\" as const,\n\tgreaterthan: \">\" as const,\n\tquestion: \"?\" as const,\n\n\t// Single modifiers\n\tctrl: <K extends BaseKey>(key: K): `ctrl+${K}` => `ctrl+${key}`,\n\tshift: <K extends BaseKey>(key: K): `shift+${K}` => `shift+${key}`,\n\talt: <K extends BaseKey>(key: K): `alt+${K}` => `alt+${key}`,\n\tsuper: <K extends BaseKey>(key: K): `super+${K}` => `super+${key}`,\n\n\t// Combined modifiers\n\tctrlShift: <K extends BaseKey>(key: K): `ctrl+shift+${K}` => `ctrl+shift+${key}`,\n\tshiftCtrl: <K extends BaseKey>(key: K): `shift+ctrl+${K}` => `shift+ctrl+${key}`,\n\tctrlAlt: <K extends BaseKey>(key: K): `ctrl+alt+${K}` => `ctrl+alt+${key}`,\n\taltCtrl: <K extends BaseKey>(key: K): `alt+ctrl+${K}` => `alt+ctrl+${key}`,\n\tshiftAlt: <K extends BaseKey>(key: K): `shift+alt+${K}` => `shift+alt+${key}`,\n\taltShift: <K extends BaseKey>(key: K): `alt+shift+${K}` => `alt+shift+${key}`,\n\tctrlSuper: <K extends BaseKey>(key: K): `ctrl+super+${K}` => `ctrl+super+${key}`,\n\tsuperCtrl: <K extends BaseKey>(key: K): `super+ctrl+${K}` => `super+ctrl+${key}`,\n\tshiftSuper: <K extends BaseKey>(key: K): `shift+super+${K}` => `shift+super+${key}`,\n\tsuperShift: <K extends BaseKey>(key: K): `super+shift+${K}` => `super+shift+${key}`,\n\taltSuper: <K extends BaseKey>(key: K): `alt+super+${K}` => `alt+super+${key}`,\n\tsuperAlt: <K extends BaseKey>(key: K): `super+alt+${K}` => `super+alt+${key}`,\n\n\t// Triple modifiers\n\tctrlShiftAlt: <K extends BaseKey>(key: K): `ctrl+shift+alt+${K}` => `ctrl+shift+alt+${key}`,\n\tctrlShiftSuper: <K extends BaseKey>(key: K): `ctrl+shift+super+${K}` => `ctrl+shift+super+${key}`,\n} as const;\n\n// =============================================================================\n// Constants\n// =============================================================================\n\nconst SYMBOL_KEYS = new Set([\n\t\"`\",\n\t\"-\",\n\t\"=\",\n\t\"[\",\n\t\"]\",\n\t\"\\\\\",\n\t\";\",\n\t\"'\",\n\t\",\",\n\t\".\",\n\t\"/\",\n\t\"!\",\n\t\"@\",\n\t\"#\",\n\t\"$\",\n\t\"%\",\n\t\"^\",\n\t\"&\",\n\t\"*\",\n\t\"(\",\n\t\")\",\n\t\"_\",\n\t\"+\",\n\t\"|\",\n\t\"~\",\n\t\"{\",\n\t\"}\",\n\t\":\",\n\t\"<\",\n\t\">\",\n\t\"?\",\n]);\n\nconst MODIFIERS = {\n\tshift: 1,\n\talt: 2,\n\tctrl: 4,\n\tsuper: 8,\n} as const;\n\nconst LOCK_MASK = 64 + 128; // Caps Lock + Num Lock\n\nconst CODEPOINTS = {\n\tescape: 27,\n\ttab: 9,\n\tenter: 13,\n\tspace: 32,\n\tbackspace: 127,\n\tkpEnter: 57414, // Numpad Enter (Kitty protocol)\n} as const;\n\nconst ARROW_CODEPOINTS = {\n\tup: -1,\n\tdown: -2,\n\tright: -3,\n\tleft: -4,\n} as const;\n\nconst FUNCTIONAL_CODEPOINTS = {\n\tdelete: -10,\n\tinsert: -11,\n\tpageUp: -12,\n\tpageDown: -13,\n\thome: -14,\n\tend: -15,\n} as const;\n\nconst KITTY_FUNCTIONAL_KEY_EQUIVALENTS = new Map<number, number>([\n\t[57399, 48], // KP_0 -> 0\n\t[57400, 49], // KP_1 -> 1\n\t[57401, 50], // KP_2 -> 2\n\t[57402, 51], // KP_3 -> 3\n\t[57403, 52], // KP_4 -> 4\n\t[57404, 53], // KP_5 -> 5\n\t[57405, 54], // KP_6 -> 6\n\t[57406, 55], // KP_7 -> 7\n\t[57407, 56], // KP_8 -> 8\n\t[57408, 57], // KP_9 -> 9\n\t[57409, 46], // KP_DECIMAL -> .\n\t[57410, 47], // KP_DIVIDE -> /\n\t[57411, 42], // KP_MULTIPLY -> *\n\t[57412, 45], // KP_SUBTRACT -> -\n\t[57413, 43], // KP_ADD -> +\n\t[57415, 61], // KP_EQUAL -> =\n\t[57416, 44], // KP_SEPARATOR -> ,\n\t[57417, ARROW_CODEPOINTS.left],\n\t[57418, ARROW_CODEPOINTS.right],\n\t[57419, ARROW_CODEPOINTS.up],\n\t[57420, ARROW_CODEPOINTS.down],\n\t[57421, FUNCTIONAL_CODEPOINTS.pageUp],\n\t[57422, FUNCTIONAL_CODEPOINTS.pageDown],\n\t[57423, FUNCTIONAL_CODEPOINTS.home],\n\t[57424, FUNCTIONAL_CODEPOINTS.end],\n\t[57425, FUNCTIONAL_CODEPOINTS.insert],\n\t[57426, FUNCTIONAL_CODEPOINTS.delete],\n]);\n\nfunction normalizeKittyFunctionalCodepoint(codepoint: number): number {\n\treturn KITTY_FUNCTIONAL_KEY_EQUIVALENTS.get(codepoint) ?? codepoint;\n}\n\nfunction normalizeShiftedLetterIdentityCodepoint(codepoint: number, modifier: number): number {\n\tconst effectiveModifier = modifier & ~LOCK_MASK;\n\tif ((effectiveModifier & MODIFIERS.shift) !== 0 && codepoint >= 65 && codepoint <= 90) {\n\t\treturn codepoint + 32;\n\t}\n\treturn codepoint;\n}\n\nconst LEGACY_KEY_SEQUENCES = {\n\tup: [\"\\x1b[A\", \"\\x1bOA\"],\n\tdown: [\"\\x1b[B\", \"\\x1bOB\"],\n\tright: [\"\\x1b[C\", \"\\x1bOC\"],\n\tleft: [\"\\x1b[D\", \"\\x1bOD\"],\n\thome: [\"\\x1b[H\", \"\\x1bOH\", \"\\x1b[1~\", \"\\x1b[7~\"],\n\tend: [\"\\x1b[F\", \"\\x1bOF\", \"\\x1b[4~\", \"\\x1b[8~\"],\n\tinsert: [\"\\x1b[2~\"],\n\tdelete: [\"\\x1b[3~\"],\n\tpageUp: [\"\\x1b[5~\", \"\\x1b[[5~\"],\n\tpageDown: [\"\\x1b[6~\", \"\\x1b[[6~\"],\n\tclear: [\"\\x1b[E\", \"\\x1bOE\"],\n\tf1: [\"\\x1bOP\", \"\\x1b[11~\", \"\\x1b[[A\"],\n\tf2: [\"\\x1bOQ\", \"\\x1b[12~\", \"\\x1b[[B\"],\n\tf3: [\"\\x1bOR\", \"\\x1b[13~\", \"\\x1b[[C\"],\n\tf4: [\"\\x1bOS\", \"\\x1b[14~\", \"\\x1b[[D\"],\n\tf5: [\"\\x1b[15~\", \"\\x1b[[E\"],\n\tf6: [\"\\x1b[17~\"],\n\tf7: [\"\\x1b[18~\"],\n\tf8: [\"\\x1b[19~\"],\n\tf9: [\"\\x1b[20~\"],\n\tf10: [\"\\x1b[21~\"],\n\tf11: [\"\\x1b[23~\"],\n\tf12: [\"\\x1b[24~\"],\n} as const;\n\nconst LEGACY_SHIFT_SEQUENCES = {\n\tup: [\"\\x1b[a\"],\n\tdown: [\"\\x1b[b\"],\n\tright: [\"\\x1b[c\"],\n\tleft: [\"\\x1b[d\"],\n\tclear: [\"\\x1b[e\"],\n\tinsert: [\"\\x1b[2$\"],\n\tdelete: [\"\\x1b[3$\"],\n\tpageUp: [\"\\x1b[5$\"],\n\tpageDown: [\"\\x1b[6$\"],\n\thome: [\"\\x1b[7$\"],\n\tend: [\"\\x1b[8$\"],\n} as const;\n\nconst LEGACY_CTRL_SEQUENCES = {\n\tup: [\"\\x1bOa\"],\n\tdown: [\"\\x1bOb\"],\n\tright: [\"\\x1bOc\"],\n\tleft: [\"\\x1bOd\"],\n\tclear: [\"\\x1bOe\"],\n\tinsert: [\"\\x1b[2^\"],\n\tdelete: [\"\\x1b[3^\"],\n\tpageUp: [\"\\x1b[5^\"],\n\tpageDown: [\"\\x1b[6^\"],\n\thome: [\"\\x1b[7^\"],\n\tend: [\"\\x1b[8^\"],\n} as const;\n\nconst LEGACY_SEQUENCE_KEY_IDS: Record<string, KeyId> = {\n\t\"\\x1bOA\": \"up\",\n\t\"\\x1bOB\": \"down\",\n\t\"\\x1bOC\": \"right\",\n\t\"\\x1bOD\": \"left\",\n\t\"\\x1bOH\": \"home\",\n\t\"\\x1bOF\": \"end\",\n\t\"\\x1b[E\": \"clear\",\n\t\"\\x1bOE\": \"clear\",\n\t\"\\x1bOe\": \"ctrl+clear\",\n\t\"\\x1b[e\": \"shift+clear\",\n\t\"\\x1b[2~\": \"insert\",\n\t\"\\x1b[2$\": \"shift+insert\",\n\t\"\\x1b[2^\": \"ctrl+insert\",\n\t\"\\x1b[3$\": \"shift+delete\",\n\t\"\\x1b[3^\": \"ctrl+delete\",\n\t\"\\x1b[[5~\": \"pageUp\",\n\t\"\\x1b[[6~\": \"pageDown\",\n\t\"\\x1b[a\": \"shift+up\",\n\t\"\\x1b[b\": \"shift+down\",\n\t\"\\x1b[c\": \"shift+right\",\n\t\"\\x1b[d\": \"shift+left\",\n\t\"\\x1bOa\": \"ctrl+up\",\n\t\"\\x1bOb\": \"ctrl+down\",\n\t\"\\x1bOc\": \"ctrl+right\",\n\t\"\\x1bOd\": \"ctrl+left\",\n\t\"\\x1b[5$\": \"shift+pageUp\",\n\t\"\\x1b[6$\": \"shift+pageDown\",\n\t\"\\x1b[7$\": \"shift+home\",\n\t\"\\x1b[8$\": \"shift+end\",\n\t\"\\x1b[5^\": \"ctrl+pageUp\",\n\t\"\\x1b[6^\": \"ctrl+pageDown\",\n\t\"\\x1b[7^\": \"ctrl+home\",\n\t\"\\x1b[8^\": \"ctrl+end\",\n\t\"\\x1bOP\": \"f1\",\n\t\"\\x1bOQ\": \"f2\",\n\t\"\\x1bOR\": \"f3\",\n\t\"\\x1bOS\": \"f4\",\n\t\"\\x1b[11~\": \"f1\",\n\t\"\\x1b[12~\": \"f2\",\n\t\"\\x1b[13~\": \"f3\",\n\t\"\\x1b[14~\": \"f4\",\n\t\"\\x1b[[A\": \"f1\",\n\t\"\\x1b[[B\": \"f2\",\n\t\"\\x1b[[C\": \"f3\",\n\t\"\\x1b[[D\": \"f4\",\n\t\"\\x1b[[E\": \"f5\",\n\t\"\\x1b[15~\": \"f5\",\n\t\"\\x1b[17~\": \"f6\",\n\t\"\\x1b[18~\": \"f7\",\n\t\"\\x1b[19~\": \"f8\",\n\t\"\\x1b[20~\": \"f9\",\n\t\"\\x1b[21~\": \"f10\",\n\t\"\\x1b[23~\": \"f11\",\n\t\"\\x1b[24~\": \"f12\",\n\t\"\\x1bb\": \"alt+left\",\n\t\"\\x1bf\": \"alt+right\",\n\t\"\\x1bp\": \"alt+up\",\n\t\"\\x1bn\": \"alt+down\",\n} as const;\n\ntype LegacyModifierKey = keyof typeof LEGACY_SHIFT_SEQUENCES;\n\nconst matchesLegacySequence = (data: string, sequences: readonly string[]): boolean => sequences.includes(data);\n\nconst matchesLegacyModifierSequence = (data: string, key: LegacyModifierKey, modifier: number): boolean => {\n\tif (modifier === MODIFIERS.shift) {\n\t\treturn matchesLegacySequence(data, LEGACY_SHIFT_SEQUENCES[key]);\n\t}\n\tif (modifier === MODIFIERS.ctrl) {\n\t\treturn matchesLegacySequence(data, LEGACY_CTRL_SEQUENCES[key]);\n\t}\n\treturn false;\n};\n\n// =============================================================================\n// Kitty Protocol Parsing\n// =============================================================================\n\n/**\n * Event types from Kitty keyboard protocol (flag 2)\n * 1 = key press, 2 = key repeat, 3 = key release\n */\nexport type KeyEventType = \"press\" | \"repeat\" | \"release\";\n\ninterface ParsedKittySequence {\n\tcodepoint: number;\n\tshiftedKey?: number; // Shifted version of the key (when shift is pressed)\n\tbaseLayoutKey?: number; // Key in standard PC-101 layout (for non-Latin layouts)\n\tmodifier: number;\n\teventType: KeyEventType;\n}\n\ninterface ParsedModifyOtherKeysSequence {\n\tcodepoint: number;\n\tmodifier: number;\n}\n\n// Store the last parsed event type for isKeyRelease() to query\nlet _lastEventType: KeyEventType = \"press\";\n\n/**\n * Check if the last parsed key event was a key release.\n * Only meaningful when Kitty keyboard protocol with flag 2 is active.\n */\nexport function isKeyRelease(data: string): boolean {\n\t// Don't treat bracketed paste content as key release, even if it contains\n\t// patterns like \":3F\" (e.g., bluetooth MAC addresses like \"90:62:3F:A5\").\n\t// Terminal.ts re-wraps paste content with bracketed paste markers before\n\t// passing to TUI, so pasted data will always contain \\x1b[200~.\n\tif (data.includes(\"\\x1b[200~\")) {\n\t\treturn false;\n\t}\n\n\t// Quick check: release events with flag 2 contain \":3\"\n\t// Format: \\x1b[<codepoint>;<modifier>:3u\n\tif (\n\t\tdata.includes(\":3u\") ||\n\t\tdata.includes(\":3~\") ||\n\t\tdata.includes(\":3A\") ||\n\t\tdata.includes(\":3B\") ||\n\t\tdata.includes(\":3C\") ||\n\t\tdata.includes(\":3D\") ||\n\t\tdata.includes(\":3H\") ||\n\t\tdata.includes(\":3F\")\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n/**\n * Check if the last parsed key event was a key repeat.\n * Only meaningful when Kitty keyboard protocol with flag 2 is active.\n */\nexport function isKeyRepeat(data: string): boolean {\n\t// Don't treat bracketed paste content as key repeat, even if it contains\n\t// patterns like \":2F\". See isKeyRelease() for details.\n\tif (data.includes(\"\\x1b[200~\")) {\n\t\treturn false;\n\t}\n\n\tif (\n\t\tdata.includes(\":2u\") ||\n\t\tdata.includes(\":2~\") ||\n\t\tdata.includes(\":2A\") ||\n\t\tdata.includes(\":2B\") ||\n\t\tdata.includes(\":2C\") ||\n\t\tdata.includes(\":2D\") ||\n\t\tdata.includes(\":2H\") ||\n\t\tdata.includes(\":2F\")\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction parseEventType(eventTypeStr: string | undefined): KeyEventType {\n\tif (!eventTypeStr) return \"press\";\n\tconst eventType = parseInt(eventTypeStr, 10);\n\tif (eventType === 2) return \"repeat\";\n\tif (eventType === 3) return \"release\";\n\treturn \"press\";\n}\n\nfunction parseKittySequence(data: string): ParsedKittySequence | null {\n\t// CSI u format with alternate keys (flag 4):\n\t// \\x1b[<codepoint>u\n\t// \\x1b[<codepoint>;<mod>u\n\t// \\x1b[<codepoint>;<mod>:<event>u\n\t// \\x1b[<codepoint>:<shifted>;<mod>u\n\t// \\x1b[<codepoint>:<shifted>:<base>;<mod>u\n\t// \\x1b[<codepoint>::<base>;<mod>u (no shifted key, only base)\n\t//\n\t// With flag 2, event type is appended after modifier colon: 1=press, 2=repeat, 3=release\n\t// With flag 4, alternate keys are appended after codepoint with colons\n\tconst csiUMatch = data.match(/^\\x1b\\[(\\d+)(?::(\\d*))?(?::(\\d+))?(?:;(\\d+))?(?::(\\d+))?u$/);\n\tif (csiUMatch) {\n\t\tconst codepoint = parseInt(csiUMatch[1]!, 10);\n\t\tconst shiftedKey = csiUMatch[2] && csiUMatch[2].length > 0 ? parseInt(csiUMatch[2], 10) : undefined;\n\t\tconst baseLayoutKey = csiUMatch[3] ? parseInt(csiUMatch[3], 10) : undefined;\n\t\tconst modValue = csiUMatch[4] ? parseInt(csiUMatch[4], 10) : 1;\n\t\tconst eventType = parseEventType(csiUMatch[5]);\n\t\t_lastEventType = eventType;\n\t\treturn { codepoint, shiftedKey, baseLayoutKey, modifier: modValue - 1, eventType };\n\t}\n\n\t// Arrow keys with modifier: \\x1b[1;<mod>A/B/C/D or \\x1b[1;<mod>:<event>A/B/C/D\n\tconst arrowMatch = data.match(/^\\x1b\\[1;(\\d+)(?::(\\d+))?([ABCD])$/);\n\tif (arrowMatch) {\n\t\tconst modValue = parseInt(arrowMatch[1]!, 10);\n\t\tconst eventType = parseEventType(arrowMatch[2]);\n\t\tconst arrowCodes: Record<string, number> = { A: -1, B: -2, C: -3, D: -4 };\n\t\t_lastEventType = eventType;\n\t\treturn { codepoint: arrowCodes[arrowMatch[3]!]!, modifier: modValue - 1, eventType };\n\t}\n\n\t// Functional keys: \\x1b[<num>~ or \\x1b[<num>;<mod>~ or \\x1b[<num>;<mod>:<event>~\n\tconst funcMatch = data.match(/^\\x1b\\[(\\d+)(?:;(\\d+))?(?::(\\d+))?~$/);\n\tif (funcMatch) {\n\t\tconst keyNum = parseInt(funcMatch[1]!, 10);\n\t\tconst modValue = funcMatch[2] ? parseInt(funcMatch[2], 10) : 1;\n\t\tconst eventType = parseEventType(funcMatch[3]);\n\t\tconst funcCodes: Record<number, number> = {\n\t\t\t2: FUNCTIONAL_CODEPOINTS.insert,\n\t\t\t3: FUNCTIONAL_CODEPOINTS.delete,\n\t\t\t5: FUNCTIONAL_CODEPOINTS.pageUp,\n\t\t\t6: FUNCTIONAL_CODEPOINTS.pageDown,\n\t\t\t7: FUNCTIONAL_CODEPOINTS.home,\n\t\t\t8: FUNCTIONAL_CODEPOINTS.end,\n\t\t};\n\t\tconst codepoint = funcCodes[keyNum];\n\t\tif (codepoint !== undefined) {\n\t\t\t_lastEventType = eventType;\n\t\t\treturn { codepoint, modifier: modValue - 1, eventType };\n\t\t}\n\t}\n\n\t// Home/End with modifier: \\x1b[1;<mod>H/F or \\x1b[1;<mod>:<event>H/F\n\tconst homeEndMatch = data.match(/^\\x1b\\[1;(\\d+)(?::(\\d+))?([HF])$/);\n\tif (homeEndMatch) {\n\t\tconst modValue = parseInt(homeEndMatch[1]!, 10);\n\t\tconst eventType = parseEventType(homeEndMatch[2]);\n\t\tconst codepoint = homeEndMatch[3] === \"H\" ? FUNCTIONAL_CODEPOINTS.home : FUNCTIONAL_CODEPOINTS.end;\n\t\t_lastEventType = eventType;\n\t\treturn { codepoint, modifier: modValue - 1, eventType };\n\t}\n\n\treturn null;\n}\n\nfunction matchesKittySequence(data: string, expectedCodepoint: number, expectedModifier: number): boolean {\n\tconst parsed = parseKittySequence(data);\n\tif (!parsed) return false;\n\tconst actualMod = parsed.modifier & ~LOCK_MASK;\n\tconst expectedMod = expectedModifier & ~LOCK_MASK;\n\n\t// Check if modifiers match\n\tif (actualMod !== expectedMod) return false;\n\n\tconst normalizedCodepoint = normalizeShiftedLetterIdentityCodepoint(\n\t\tnormalizeKittyFunctionalCodepoint(parsed.codepoint),\n\t\tparsed.modifier,\n\t);\n\tconst normalizedExpectedCodepoint = normalizeShiftedLetterIdentityCodepoint(\n\t\tnormalizeKittyFunctionalCodepoint(expectedCodepoint),\n\t\texpectedModifier,\n\t);\n\n\t// Primary match: codepoint matches directly after normalizing functional keys\n\tif (normalizedCodepoint === normalizedExpectedCodepoint) return true;\n\n\t// Alternate match: use base layout key for non-Latin keyboard layouts.\n\t// This allows Ctrl+С (Cyrillic) to match Ctrl+c (Latin) when terminal reports\n\t// the base layout key (the key in standard PC-101 layout).\n\t//\n\t// Only fall back to base layout key when the codepoint is NOT already a\n\t// recognized Latin letter (a-z) or symbol (e.g., /, -, [, ;, etc.).\n\t// When the codepoint is a recognized key, it is authoritative regardless\n\t// of physical key position. This prevents remapped layouts (Dvorak, Colemak,\n\t// xremap, etc.) from causing false matches: both letters and symbols move\n\t// to different physical positions, so Ctrl+K could falsely match Ctrl+V\n\t// (letter remapping) and Ctrl+/ could falsely match Ctrl+[ (symbol remapping)\n\t// if the base layout key were always considered.\n\tif (parsed.baseLayoutKey !== undefined && parsed.baseLayoutKey === expectedCodepoint) {\n\t\tconst cp = normalizedCodepoint;\n\t\tconst isLatinLetter = cp >= 97 && cp <= 122; // a-z\n\t\tconst isKnownSymbol = SYMBOL_KEYS.has(String.fromCharCode(cp));\n\t\tif (!isLatinLetter && !isKnownSymbol) return true;\n\t}\n\n\treturn false;\n}\n\nfunction parseModifyOtherKeysSequence(data: string): ParsedModifyOtherKeysSequence | null {\n\tconst match = data.match(/^\\x1b\\[27;(\\d+);(\\d+)~$/);\n\tif (!match) return null;\n\tconst modValue = parseInt(match[1]!, 10);\n\tconst codepoint = parseInt(match[2]!, 10);\n\treturn { codepoint, modifier: modValue - 1 };\n}\n\n/**\n * Match xterm modifyOtherKeys format: CSI 27 ; modifiers ; keycode ~\n * This is used by terminals when Kitty protocol is not enabled.\n * Modifier values are 1-indexed: 2=shift, 3=alt, 5=ctrl, etc.\n */\nfunction matchesModifyOtherKeys(data: string, expectedKeycode: number, expectedModifier: number): boolean {\n\tconst parsed = parseModifyOtherKeysSequence(data);\n\tif (!parsed) return false;\n\treturn parsed.codepoint === expectedKeycode && parsed.modifier === expectedModifier;\n}\n\nfunction isWindowsTerminalSession(): boolean {\n\treturn (\n\t\tBoolean(process.env.WT_SESSION) && !process.env.SSH_CONNECTION && !process.env.SSH_CLIENT && !process.env.SSH_TTY\n\t);\n}\n\n/**\n * Raw 0x08 (BS) is ambiguous in legacy terminals.\n *\n * - Windows Terminal uses it for Ctrl+Backspace.\n * - Some legacy terminals and tmux setups send it for plain Backspace.\n *\n * Prefer explicit Kitty / CSI-u / modifyOtherKeys sequences whenever they are\n * available. Fall back to a Windows Terminal heuristic only for raw BS bytes.\n */\nfunction matchesRawBackspace(data: string, expectedModifier: number): boolean {\n\tif (data === \"\\x7f\") return expectedModifier === 0;\n\tif (data !== \"\\x08\") return false;\n\treturn isWindowsTerminalSession() ? expectedModifier === MODIFIERS.ctrl : expectedModifier === 0;\n}\n\n// =============================================================================\n// Generic Key Matching\n// =============================================================================\n\n/**\n * Get the control character for a key.\n * Uses the universal formula: code & 0x1f (mask to lower 5 bits)\n *\n * Works for:\n * - Letters a-z → 1-26\n * - Symbols [\\]_ → 27, 28, 29, 31\n * - Also maps - to same as _ (same physical key on US keyboards)\n */\nfunction rawCtrlChar(key: string): string | null {\n\tconst char = key.toLowerCase();\n\tconst code = char.charCodeAt(0);\n\tif ((code >= 97 && code <= 122) || char === \"[\" || char === \"\\\\\" || char === \"]\" || char === \"_\") {\n\t\treturn String.fromCharCode(code & 0x1f);\n\t}\n\t// Handle - as _ (same physical key on US keyboards)\n\tif (char === \"-\") {\n\t\treturn String.fromCharCode(31); // Same as Ctrl+_\n\t}\n\treturn null;\n}\n\nfunction isDigitKey(key: string): boolean {\n\treturn key >= \"0\" && key <= \"9\";\n}\n\nfunction matchesPrintableModifyOtherKeys(data: string, expectedKeycode: number, expectedModifier: number): boolean {\n\tif (expectedModifier === 0) return false;\n\tconst parsed = parseModifyOtherKeysSequence(data);\n\tif (!parsed || parsed.modifier !== expectedModifier) return false;\n\treturn (\n\t\tnormalizeShiftedLetterIdentityCodepoint(parsed.codepoint, parsed.modifier) ===\n\t\tnormalizeShiftedLetterIdentityCodepoint(expectedKeycode, expectedModifier)\n\t);\n}\n\nfunction formatKeyNameWithModifiers(keyName: string, modifier: number): string | undefined {\n\tconst mods: string[] = [];\n\tconst effectiveMod = modifier & ~LOCK_MASK;\n\tconst supportedModifierMask = MODIFIERS.shift | MODIFIERS.ctrl | MODIFIERS.alt | MODIFIERS.super;\n\tif ((effectiveMod & ~supportedModifierMask) !== 0) return undefined;\n\tif (effectiveMod & MODIFIERS.shift) mods.push(\"shift\");\n\tif (effectiveMod & MODIFIERS.ctrl) mods.push(\"ctrl\");\n\tif (effectiveMod & MODIFIERS.alt) mods.push(\"alt\");\n\tif (effectiveMod & MODIFIERS.super) mods.push(\"super\");\n\treturn mods.length > 0 ? `${mods.join(\"+\")}+${keyName}` : keyName;\n}\n\nfunction parseKeyId(\n\tkeyId: string,\n): { key: string; ctrl: boolean; shift: boolean; alt: boolean; super: boolean } | null {\n\tconst parts = keyId.toLowerCase().split(\"+\");\n\tconst key = parts[parts.length - 1];\n\tif (!key) return null;\n\treturn {\n\t\tkey,\n\t\tctrl: parts.includes(\"ctrl\"),\n\t\tshift: parts.includes(\"shift\"),\n\t\talt: parts.includes(\"alt\"),\n\t\tsuper: parts.includes(\"super\"),\n\t};\n}\n\n/**\n * Match input data against a key identifier string.\n *\n * Supported key identifiers:\n * - Single keys: \"escape\", \"tab\", \"enter\", \"backspace\", \"delete\", \"home\", \"end\", \"space\"\n * - Arrow keys: \"up\", \"down\", \"left\", \"right\"\n * - Ctrl combinations: \"ctrl+c\", \"ctrl+z\", etc.\n * - Shift combinations: \"shift+tab\", \"shift+enter\"\n * - Alt combinations: \"alt+enter\", \"alt+backspace\"\n * - Super combinations: \"super+k\", \"super+enter\"\n * - Combined modifiers: \"shift+ctrl+p\", \"ctrl+alt+x\", \"ctrl+super+k\"\n *\n * Use the Key helper for autocomplete: Key.ctrl(\"c\"), Key.escape, Key.ctrlShift(\"p\"), Key.super(\"k\")\n *\n * @param data - Raw input data from terminal\n * @param keyId - Key identifier (e.g., \"ctrl+c\", \"escape\", Key.ctrl(\"c\"))\n */\nexport function matchesKey(data: string, keyId: KeyId): boolean {\n\tconst parsed = parseKeyId(keyId);\n\tif (!parsed) return false;\n\n\tconst { key, ctrl, shift, alt, super: superModifier } = parsed;\n\tlet modifier = 0;\n\tif (shift) modifier |= MODIFIERS.shift;\n\tif (alt) modifier |= MODIFIERS.alt;\n\tif (ctrl) modifier |= MODIFIERS.ctrl;\n\tif (superModifier) modifier |= MODIFIERS.super;\n\n\tswitch (key) {\n\t\tcase \"escape\":\n\t\tcase \"esc\":\n\t\t\tif (modifier !== 0) return false;\n\t\t\treturn (\n\t\t\t\tdata === \"\\x1b\" ||\n\t\t\t\tmatchesKittySequence(data, CODEPOINTS.escape, 0) ||\n\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.escape, 0)\n\t\t\t);\n\n\t\tcase \"space\":\n\t\t\tif (!_kittyProtocolActive) {\n\t\t\t\tif (modifier === MODIFIERS.ctrl && data === \"\\x00\") {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (modifier === MODIFIERS.alt && data === \"\\x1b \") {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \" \" ||\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.space, 0) ||\n\t\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.space, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, CODEPOINTS.space, modifier) ||\n\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.space, modifier)\n\t\t\t);\n\n\t\tcase \"tab\":\n\t\t\tif (modifier === MODIFIERS.shift) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\x1b[Z\" ||\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.tab, MODIFIERS.shift) ||\n\t\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.tab, MODIFIERS.shift)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn data === \"\\t\" || matchesKittySequence(data, CODEPOINTS.tab, 0);\n\t\t\t}\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, CODEPOINTS.tab, modifier) ||\n\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.tab, modifier)\n\t\t\t);\n\n\t\tcase \"enter\":\n\t\tcase \"return\":\n\t\t\tif (modifier === MODIFIERS.shift) {\n\t\t\t\t// CSI u sequences (standard Kitty protocol)\n\t\t\t\tif (\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.enter, MODIFIERS.shift) ||\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.kpEnter, MODIFIERS.shift)\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// xterm modifyOtherKeys format (fallback when Kitty protocol not enabled)\n\t\t\t\tif (matchesModifyOtherKeys(data, CODEPOINTS.enter, MODIFIERS.shift)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// When Kitty protocol is active, legacy sequences are custom terminal mappings\n\t\t\t\t// \\x1b\\r = Kitty's \"map shift+enter send_text all \\e\\r\"\n\t\t\t\t// \\n = Ghostty's \"keybind = shift+enter=text:\\n\"\n\t\t\t\tif (_kittyProtocolActive) {\n\t\t\t\t\treturn data === \"\\x1b\\r\" || data === \"\\n\";\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (modifier === MODIFIERS.alt) {\n\t\t\t\t// CSI u sequences (standard Kitty protocol)\n\t\t\t\tif (\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.enter, MODIFIERS.alt) ||\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.kpEnter, MODIFIERS.alt)\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// xterm modifyOtherKeys format (fallback when Kitty protocol not enabled)\n\t\t\t\tif (matchesModifyOtherKeys(data, CODEPOINTS.enter, MODIFIERS.alt)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\t// \\x1b\\r is alt+enter only in legacy mode (no Kitty protocol)\n\t\t\t\t// When Kitty protocol is active, alt+enter comes as CSI u sequence\n\t\t\t\tif (!_kittyProtocolActive) {\n\t\t\t\t\treturn data === \"\\x1b\\r\";\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\r\" ||\n\t\t\t\t\t(!_kittyProtocolActive && data === \"\\n\") ||\n\t\t\t\t\tdata === \"\\x1bOM\" || // SS3 M (numpad enter in some terminals)\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.enter, 0) ||\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.kpEnter, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, CODEPOINTS.enter, modifier) ||\n\t\t\t\tmatchesKittySequence(data, CODEPOINTS.kpEnter, modifier) ||\n\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.enter, modifier)\n\t\t\t);\n\n\t\tcase \"backspace\":\n\t\t\tif (modifier === MODIFIERS.alt) {\n\t\t\t\tif (data === \"\\x1b\\x7f\" || data === \"\\x1b\\b\") {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.backspace, MODIFIERS.alt) ||\n\t\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.backspace, MODIFIERS.alt)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (modifier === MODIFIERS.ctrl) {\n\t\t\t\t// Legacy raw 0x08 is ambiguous: it can be Ctrl+Backspace on Windows\n\t\t\t\t// Terminal or plain Backspace on other terminals, while also\n\t\t\t\t// overlapping with Ctrl+H.\n\t\t\t\tif (matchesRawBackspace(data, MODIFIERS.ctrl)) return true;\n\t\t\t\treturn (\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.backspace, MODIFIERS.ctrl) ||\n\t\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.backspace, MODIFIERS.ctrl)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesRawBackspace(data, 0) ||\n\t\t\t\t\tmatchesKittySequence(data, CODEPOINTS.backspace, 0) ||\n\t\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.backspace, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, CODEPOINTS.backspace, modifier) ||\n\t\t\t\tmatchesModifyOtherKeys(data, CODEPOINTS.backspace, modifier)\n\t\t\t);\n\n\t\tcase \"insert\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.insert) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.insert, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"insert\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.insert, modifier);\n\n\t\tcase \"delete\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.delete) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.delete, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"delete\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.delete, modifier);\n\n\t\tcase \"clear\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn matchesLegacySequence(data, LEGACY_KEY_SEQUENCES.clear);\n\t\t\t}\n\t\t\treturn matchesLegacyModifierSequence(data, \"clear\", modifier);\n\n\t\tcase \"home\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.home) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.home, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"home\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.home, modifier);\n\n\t\tcase \"end\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.end) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.end, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"end\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.end, modifier);\n\n\t\tcase \"pageup\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.pageUp) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.pageUp, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"pageUp\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.pageUp, modifier);\n\n\t\tcase \"pagedown\":\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.pageDown) ||\n\t\t\t\t\tmatchesKittySequence(data, FUNCTIONAL_CODEPOINTS.pageDown, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"pageDown\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, FUNCTIONAL_CODEPOINTS.pageDown, modifier);\n\n\t\tcase \"up\":\n\t\t\tif (modifier === MODIFIERS.alt) {\n\t\t\t\treturn data === \"\\x1bp\" || matchesKittySequence(data, ARROW_CODEPOINTS.up, MODIFIERS.alt);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.up) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.up, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"up\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, ARROW_CODEPOINTS.up, modifier);\n\n\t\tcase \"down\":\n\t\t\tif (modifier === MODIFIERS.alt) {\n\t\t\t\treturn data === \"\\x1bn\" || matchesKittySequence(data, ARROW_CODEPOINTS.down, MODIFIERS.alt);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.down) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.down, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"down\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, ARROW_CODEPOINTS.down, modifier);\n\n\t\tcase \"left\":\n\t\t\tif (modifier === MODIFIERS.alt) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\x1b[1;3D\" ||\n\t\t\t\t\t(!_kittyProtocolActive && data === \"\\x1bB\") ||\n\t\t\t\t\tdata === \"\\x1bb\" ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.left, MODIFIERS.alt)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (modifier === MODIFIERS.ctrl) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\x1b[1;5D\" ||\n\t\t\t\t\tmatchesLegacyModifierSequence(data, \"left\", MODIFIERS.ctrl) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.left, MODIFIERS.ctrl)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.left) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.left, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"left\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, ARROW_CODEPOINTS.left, modifier);\n\n\t\tcase \"right\":\n\t\t\tif (modifier === MODIFIERS.alt) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\x1b[1;3C\" ||\n\t\t\t\t\t(!_kittyProtocolActive && data === \"\\x1bF\") ||\n\t\t\t\t\tdata === \"\\x1bf\" ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.right, MODIFIERS.alt)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (modifier === MODIFIERS.ctrl) {\n\t\t\t\treturn (\n\t\t\t\t\tdata === \"\\x1b[1;5C\" ||\n\t\t\t\t\tmatchesLegacyModifierSequence(data, \"right\", MODIFIERS.ctrl) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.right, MODIFIERS.ctrl)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (modifier === 0) {\n\t\t\t\treturn (\n\t\t\t\t\tmatchesLegacySequence(data, LEGACY_KEY_SEQUENCES.right) ||\n\t\t\t\t\tmatchesKittySequence(data, ARROW_CODEPOINTS.right, 0)\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (matchesLegacyModifierSequence(data, \"right\", modifier)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treturn matchesKittySequence(data, ARROW_CODEPOINTS.right, modifier);\n\n\t\tcase \"f1\":\n\t\tcase \"f2\":\n\t\tcase \"f3\":\n\t\tcase \"f4\":\n\t\tcase \"f5\":\n\t\tcase \"f6\":\n\t\tcase \"f7\":\n\t\tcase \"f8\":\n\t\tcase \"f9\":\n\t\tcase \"f10\":\n\t\tcase \"f11\":\n\t\tcase \"f12\": {\n\t\t\tif (modifier !== 0) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst functionKey = key as keyof typeof LEGACY_KEY_SEQUENCES;\n\t\t\treturn matchesLegacySequence(data, LEGACY_KEY_SEQUENCES[functionKey]);\n\t\t}\n\t}\n\n\t// Handle single letter/digit keys and symbols\n\tif (key.length === 1 && ((key >= \"a\" && key <= \"z\") || isDigitKey(key) || SYMBOL_KEYS.has(key))) {\n\t\tconst codepoint = key.charCodeAt(0);\n\t\tconst rawCtrl = rawCtrlChar(key);\n\t\tconst isLetter = key >= \"a\" && key <= \"z\";\n\t\tconst isDigit = isDigitKey(key);\n\n\t\tif (modifier === MODIFIERS.ctrl + MODIFIERS.alt && !_kittyProtocolActive && rawCtrl) {\n\t\t\t// Legacy: ctrl+alt+key is ESC followed by the control character.\n\t\t\t// If that legacy form does not match, continue so CSI-u and\n\t\t\t// modifyOtherKeys sequences from tmux can still be recognized.\n\t\t\tif (data === `\\x1b${rawCtrl}`) return true;\n\t\t}\n\n\t\tif (modifier === MODIFIERS.alt && !_kittyProtocolActive && (isLetter || isDigit || SYMBOL_KEYS.has(key))) {\n\t\t\t// Legacy: alt+printable key is ESC followed by the key\n\t\t\tif (data === `\\x1b${key}`) return true;\n\t\t}\n\n\t\tif (modifier === MODIFIERS.ctrl) {\n\t\t\t// Legacy: ctrl+key sends the control character\n\t\t\tif (rawCtrl && data === rawCtrl) return true;\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, codepoint, MODIFIERS.ctrl) ||\n\t\t\t\tmatchesPrintableModifyOtherKeys(data, codepoint, MODIFIERS.ctrl)\n\t\t\t);\n\t\t}\n\n\t\tif (modifier === MODIFIERS.shift + MODIFIERS.ctrl) {\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, codepoint, MODIFIERS.shift + MODIFIERS.ctrl) ||\n\t\t\t\tmatchesPrintableModifyOtherKeys(data, codepoint, MODIFIERS.shift + MODIFIERS.ctrl)\n\t\t\t);\n\t\t}\n\n\t\tif (modifier === MODIFIERS.shift) {\n\t\t\t// Legacy: shift+letter produces uppercase\n\t\t\tif (isLetter && data === key.toUpperCase()) return true;\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, codepoint, MODIFIERS.shift) ||\n\t\t\t\tmatchesPrintableModifyOtherKeys(data, codepoint, MODIFIERS.shift)\n\t\t\t);\n\t\t}\n\n\t\tif (modifier !== 0) {\n\t\t\treturn (\n\t\t\t\tmatchesKittySequence(data, codepoint, modifier) ||\n\t\t\t\tmatchesPrintableModifyOtherKeys(data, codepoint, modifier)\n\t\t\t);\n\t\t}\n\n\t\t// Check both raw char and Kitty sequence (needed for release events)\n\t\treturn data === key || matchesKittySequence(data, codepoint, 0);\n\t}\n\n\treturn false;\n}\n\n/**\n * Parse input data and return the key identifier if recognized.\n *\n * @param data - Raw input data from terminal\n * @returns Key identifier string (e.g., \"ctrl+c\") or undefined\n */\nfunction formatParsedKey(codepoint: number, modifier: number, baseLayoutKey?: number): string | undefined {\n\tconst normalizedCodepoint = normalizeKittyFunctionalCodepoint(codepoint);\n\tconst identityCodepoint = normalizeShiftedLetterIdentityCodepoint(normalizedCodepoint, modifier);\n\n\t// Use base layout key only when codepoint is not a recognized Latin\n\t// letter (a-z), digit (0-9), or symbol (/, -, [, ;, etc.). For those,\n\t// the codepoint is authoritative regardless of physical key position.\n\t// This prevents remapped layouts (Dvorak, Colemak, xremap, etc.) from\n\t// reporting the wrong key name based on the QWERTY physical position.\n\tconst isLatinLetter = identityCodepoint >= 97 && identityCodepoint <= 122; // a-z\n\tconst isDigit = identityCodepoint >= 48 && identityCodepoint <= 57; // 0-9\n\tconst isKnownSymbol = SYMBOL_KEYS.has(String.fromCharCode(identityCodepoint));\n\tconst effectiveCodepoint =\n\t\tisLatinLetter || isDigit || isKnownSymbol ? identityCodepoint : (baseLayoutKey ?? identityCodepoint);\n\n\tlet keyName: string | undefined;\n\tif (effectiveCodepoint === CODEPOINTS.escape) keyName = \"escape\";\n\telse if (effectiveCodepoint === CODEPOINTS.tab) keyName = \"tab\";\n\telse if (effectiveCodepoint === CODEPOINTS.enter || effectiveCodepoint === CODEPOINTS.kpEnter) keyName = \"enter\";\n\telse if (effectiveCodepoint === CODEPOINTS.space) keyName = \"space\";\n\telse if (effectiveCodepoint === CODEPOINTS.backspace) keyName = \"backspace\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.delete) keyName = \"delete\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.insert) keyName = \"insert\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.home) keyName = \"home\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.end) keyName = \"end\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.pageUp) keyName = \"pageUp\";\n\telse if (effectiveCodepoint === FUNCTIONAL_CODEPOINTS.pageDown) keyName = \"pageDown\";\n\telse if (effectiveCodepoint === ARROW_CODEPOINTS.up) keyName = \"up\";\n\telse if (effectiveCodepoint === ARROW_CODEPOINTS.down) keyName = \"down\";\n\telse if (effectiveCodepoint === ARROW_CODEPOINTS.left) keyName = \"left\";\n\telse if (effectiveCodepoint === ARROW_CODEPOINTS.right) keyName = \"right\";\n\telse if (effectiveCodepoint >= 48 && effectiveCodepoint <= 57) keyName = String.fromCharCode(effectiveCodepoint);\n\telse if (effectiveCodepoint >= 97 && effectiveCodepoint <= 122) keyName = String.fromCharCode(effectiveCodepoint);\n\telse if (SYMBOL_KEYS.has(String.fromCharCode(effectiveCodepoint))) keyName = String.fromCharCode(effectiveCodepoint);\n\n\tif (!keyName) return undefined;\n\treturn formatKeyNameWithModifiers(keyName, modifier);\n}\n\nexport function parseKey(data: string): string | undefined {\n\tconst kitty = parseKittySequence(data);\n\tif (kitty) {\n\t\treturn formatParsedKey(kitty.codepoint, kitty.modifier, kitty.baseLayoutKey);\n\t}\n\n\tconst modifyOtherKeys = parseModifyOtherKeysSequence(data);\n\tif (modifyOtherKeys) {\n\t\treturn formatParsedKey(modifyOtherKeys.codepoint, modifyOtherKeys.modifier);\n\t}\n\n\t// Mode-aware legacy sequences\n\t// When Kitty protocol is active, ambiguous sequences are interpreted as custom terminal mappings:\n\t// - \\x1b\\r = shift+enter (Kitty mapping), not alt+enter\n\t// - \\n = shift+enter (Ghostty mapping)\n\tif (_kittyProtocolActive) {\n\t\tif (data === \"\\x1b\\r\" || data === \"\\n\") return \"shift+enter\";\n\t}\n\n\tconst legacySequenceKeyId = LEGACY_SEQUENCE_KEY_IDS[data];\n\tif (legacySequenceKeyId) return legacySequenceKeyId;\n\n\t// Legacy sequences (used when Kitty protocol is not active, or for unambiguous sequences)\n\tif (data === \"\\x1b\") return \"escape\";\n\tif (data === \"\\x1c\") return \"ctrl+\\\\\";\n\tif (data === \"\\x1d\") return \"ctrl+]\";\n\tif (data === \"\\x1f\") return \"ctrl+-\";\n\tif (data === \"\\x1b\\x1b\") return \"ctrl+alt+[\";\n\tif (data === \"\\x1b\\x1c\") return \"ctrl+alt+\\\\\";\n\tif (data === \"\\x1b\\x1d\") return \"ctrl+alt+]\";\n\tif (data === \"\\x1b\\x1f\") return \"ctrl+alt+-\";\n\tif (data === \"\\t\") return \"tab\";\n\tif (data === \"\\r\" || (!_kittyProtocolActive && data === \"\\n\") || data === \"\\x1bOM\") return \"enter\";\n\tif (data === \"\\x00\") return \"ctrl+space\";\n\tif (data === \" \") return \"space\";\n\tif (data === \"\\x7f\") return \"backspace\";\n\tif (data === \"\\x08\") return isWindowsTerminalSession() ? \"ctrl+backspace\" : \"backspace\";\n\tif (data === \"\\x1b[Z\") return \"shift+tab\";\n\tif (!_kittyProtocolActive && data === \"\\x1b\\r\") return \"alt+enter\";\n\tif (!_kittyProtocolActive && data === \"\\x1b \") return \"alt+space\";\n\tif (data === \"\\x1b\\x7f\" || data === \"\\x1b\\b\") return \"alt+backspace\";\n\tif (!_kittyProtocolActive && data === \"\\x1bB\") return \"alt+left\";\n\tif (!_kittyProtocolActive && data === \"\\x1bF\") return \"alt+right\";\n\tif (!_kittyProtocolActive && data.length === 2 && data[0] === \"\\x1b\") {\n\t\tconst code = data.charCodeAt(1);\n\t\tif (code >= 1 && code <= 26) {\n\t\t\treturn `ctrl+alt+${String.fromCharCode(code + 96)}`;\n\t\t}\n\t\t// Legacy alt+letter/digit/symbol (ESC followed by the key)\n\t\tconst key = String.fromCharCode(code);\n\t\tif ((code >= 97 && code <= 122) || (code >= 48 && code <= 57) || SYMBOL_KEYS.has(key)) {\n\t\t\treturn `alt+${key}`;\n\t\t}\n\t}\n\tif (data === \"\\x1b[A\") return \"up\";\n\tif (data === \"\\x1b[B\") return \"down\";\n\tif (data === \"\\x1b[C\") return \"right\";\n\tif (data === \"\\x1b[D\") return \"left\";\n\tif (data === \"\\x1b[H\" || data === \"\\x1bOH\") return \"home\";\n\tif (data === \"\\x1b[F\" || data === \"\\x1bOF\") return \"end\";\n\tif (data === \"\\x1b[3~\") return \"delete\";\n\tif (data === \"\\x1b[5~\") return \"pageUp\";\n\tif (data === \"\\x1b[6~\") return \"pageDown\";\n\n\t// Raw Ctrl+letter\n\tif (data.length === 1) {\n\t\tconst code = data.charCodeAt(0);\n\t\tif (code >= 1 && code <= 26) {\n\t\t\treturn `ctrl+${String.fromCharCode(code + 96)}`;\n\t\t}\n\t\tif (code >= 32 && code <= 126) {\n\t\t\treturn data;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n// =============================================================================\n// Kitty CSI-u Printable Decoding\n// =============================================================================\n\nconst KITTY_CSI_U_REGEX = /^\\x1b\\[(\\d+)(?::(\\d*))?(?::(\\d+))?(?:;(\\d+))?(?::(\\d+))?u$/;\nconst KITTY_PRINTABLE_ALLOWED_MODIFIERS = MODIFIERS.shift | LOCK_MASK;\n\n/**\n * Decode a Kitty CSI-u sequence into a printable character, if applicable.\n *\n * When Kitty keyboard protocol flag 1 (disambiguate) is active, terminals send\n * CSI-u sequences for all keys, including plain printable characters. This\n * function extracts the printable character from such sequences.\n *\n * Only accepts plain or Shift-modified keys. Rejects Ctrl, Alt, and unsupported\n * modifier combinations (those are handled by keybinding matching instead).\n * Prefers the shifted keycode when Shift is held and a shifted key is reported.\n *\n * @param data - Raw input data from terminal\n * @returns The printable character, or undefined if not a printable CSI-u sequence\n */\nexport function decodeKittyPrintable(data: string): string | undefined {\n\tconst match = data.match(KITTY_CSI_U_REGEX);\n\tif (!match) return undefined;\n\n\t// CSI-u groups: <codepoint>[:<shifted>[:<base>]];<mod>[:<event>]u\n\tconst codepoint = Number.parseInt(match[1] ?? \"\", 10);\n\tif (!Number.isFinite(codepoint)) return undefined;\n\n\tconst shiftedKey = match[2] && match[2].length > 0 ? Number.parseInt(match[2], 10) : undefined;\n\tconst modValue = match[4] ? Number.parseInt(match[4], 10) : 1;\n\t// Modifiers are 1-indexed in CSI-u; normalize to our bitmask.\n\tconst modifier = Number.isFinite(modValue) ? modValue - 1 : 0;\n\n\t// Only accept printable CSI-u input for plain or Shift-modified text keys.\n\t// Reject unsupported modifier bits (e.g. Super/Meta) to avoid inserting\n\t// characters from modifier-only terminal events.\n\tif ((modifier & ~KITTY_PRINTABLE_ALLOWED_MODIFIERS) !== 0) return undefined;\n\tif (modifier & (MODIFIERS.alt | MODIFIERS.ctrl)) return undefined;\n\n\t// Prefer the shifted keycode when Shift is held.\n\tlet effectiveCodepoint = codepoint;\n\tif (modifier & MODIFIERS.shift && typeof shiftedKey === \"number\") {\n\t\teffectiveCodepoint = shiftedKey;\n\t}\n\teffectiveCodepoint = normalizeKittyFunctionalCodepoint(effectiveCodepoint);\n\t// Drop control characters or invalid codepoints.\n\tif (!Number.isFinite(effectiveCodepoint) || effectiveCodepoint < 32) return undefined;\n\n\ttry {\n\t\treturn String.fromCodePoint(effectiveCodepoint);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction decodeModifyOtherKeysPrintable(data: string): string | undefined {\n\tconst parsed = parseModifyOtherKeysSequence(data);\n\tif (!parsed) return undefined;\n\tconst modifier = parsed.modifier & ~LOCK_MASK;\n\tif ((modifier & ~MODIFIERS.shift) !== 0) return undefined;\n\tif (!Number.isFinite(parsed.codepoint) || parsed.codepoint < 32) return undefined;\n\n\ttry {\n\t\treturn String.fromCodePoint(parsed.codepoint);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function decodePrintableKey(data: string): string | undefined {\n\treturn decodeKittyPrintable(data) ?? decodeModifyOtherKeysPrintable(data);\n}\n","// @ts-nocheck — vendored Pi source; checked upstream under Pi's own tsconfig.\nexport interface RgbColor {\n\tr: number;\n\tg: number;\n\tb: number;\n}\n\nexport type TerminalColorScheme = \"dark\" | \"light\";\n\nfunction hexToRgb(hex: string): RgbColor {\n\tconst normalized = hex.startsWith(\"#\") ? hex.slice(1) : hex;\n\tconst r = parseInt(normalized.slice(0, 2), 16);\n\tconst g = parseInt(normalized.slice(2, 4), 16);\n\tconst b = parseInt(normalized.slice(4, 6), 16);\n\treturn { r, g, b };\n}\n\nfunction parseOscHexChannel(channel: string): number | undefined {\n\tif (!/^[0-9a-f]+$/i.test(channel)) {\n\t\treturn undefined;\n\t}\n\tconst max = 16 ** channel.length - 1;\n\tif (max <= 0) {\n\t\treturn undefined;\n\t}\n\treturn Math.round((parseInt(channel, 16) / max) * 255);\n}\n\nconst OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN = /^\\x1b\\]11;([^\\x07\\x1b]*)(?:\\x07|\\x1b\\\\)$/i;\nconst COLOR_SCHEME_REPORT_PATTERN = /^(?:\\x1b\\[\\?997;(1|2)n)+$/;\n\nexport function isOsc11BackgroundColorResponse(data: string): boolean {\n\treturn OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN.test(data);\n}\n\nexport function parseOsc11BackgroundColor(data: string): RgbColor | undefined {\n\tconst match = data.match(OSC11_BACKGROUND_COLOR_RESPONSE_PATTERN);\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\n\tconst value = match[1].trim();\n\tif (value.startsWith(\"#\")) {\n\t\tconst hex = value.slice(1);\n\t\tif (/^[0-9a-f]{6}$/i.test(hex)) {\n\t\t\treturn hexToRgb(value);\n\t\t}\n\t\tif (/^[0-9a-f]{12}$/i.test(hex)) {\n\t\t\tconst r = parseOscHexChannel(hex.slice(0, 4));\n\t\t\tconst g = parseOscHexChannel(hex.slice(4, 8));\n\t\t\tconst b = parseOscHexChannel(hex.slice(8, 12));\n\t\t\treturn r !== undefined && g !== undefined && b !== undefined ? { r, g, b } : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tconst rgbValue = value.replace(/^rgba?:/i, \"\");\n\tconst [red, green, blue] = rgbValue.split(\"/\");\n\tif (red === undefined || green === undefined || blue === undefined) {\n\t\treturn undefined;\n\t}\n\tconst r = parseOscHexChannel(red);\n\tconst g = parseOscHexChannel(green);\n\tconst b = parseOscHexChannel(blue);\n\treturn r !== undefined && g !== undefined && b !== undefined ? { r, g, b } : undefined;\n}\n\nexport function parseTerminalColorSchemeReport(data: string): TerminalColorScheme | undefined {\n\tconst match = data.match(COLOR_SCHEME_REPORT_PATTERN);\n\tif (!match) {\n\t\treturn undefined;\n\t}\n\treturn match[1] === \"2\" ? \"light\" : \"dark\";\n}\n","// @ts-nocheck — vendored Pi source; checked upstream under Pi's own tsconfig.\nimport { type KeyId, matchesKey } from \"./pi-tui-keys.ts\";\n\n/**\n * Global keybinding registry.\n * Downstream packages can add keybindings via declaration merging.\n */\nexport interface Keybindings {\n\t// Editor navigation and editing\n\t\"tui.editor.cursorUp\": true;\n\t\"tui.editor.cursorDown\": true;\n\t\"tui.editor.historyPrevious\": true;\n\t\"tui.editor.historyNext\": true;\n\t\"tui.editor.cursorLeft\": true;\n\t\"tui.editor.cursorRight\": true;\n\t\"tui.editor.cursorWordLeft\": true;\n\t\"tui.editor.cursorWordRight\": true;\n\t\"tui.editor.cursorLineStart\": true;\n\t\"tui.editor.cursorLineEnd\": true;\n\t\"tui.editor.jumpForward\": true;\n\t\"tui.editor.jumpBackward\": true;\n\t\"tui.editor.pageUp\": true;\n\t\"tui.editor.pageDown\": true;\n\t\"tui.editor.deleteCharBackward\": true;\n\t\"tui.editor.deleteCharForward\": true;\n\t\"tui.editor.deleteWordBackward\": true;\n\t\"tui.editor.deleteWordForward\": true;\n\t\"tui.editor.deleteToLineStart\": true;\n\t\"tui.editor.deleteToLineEnd\": true;\n\t\"tui.editor.yank\": true;\n\t\"tui.editor.yankPop\": true;\n\t\"tui.editor.undo\": true;\n\t// Generic input actions\n\t\"tui.input.newLine\": true;\n\t\"tui.input.submit\": true;\n\t\"tui.input.tab\": true;\n\t\"tui.input.copy\": true;\n\t// Generic selection actions\n\t\"tui.select.up\": true;\n\t\"tui.select.down\": true;\n\t\"tui.select.pageUp\": true;\n\t\"tui.select.pageDown\": true;\n\t\"tui.select.confirm\": true;\n\t\"tui.select.cancel\": true;\n\t// Alternate-screen viewport navigation\n\t\"tui.altScreen.pageUp\": true;\n\t\"tui.altScreen.pageDown\": true;\n\t\"tui.altScreen.halfPageUp\": true;\n\t\"tui.altScreen.halfPageDown\": true;\n\t\"tui.altScreen.lineUp\": true;\n\t\"tui.altScreen.lineDown\": true;\n\t\"tui.altScreen.previousPrompt\": true;\n\t\"tui.altScreen.nextPrompt\": true;\n\t\"tui.altScreen.search\": true;\n\t\"tui.altScreen.searchNext\": true;\n\t\"tui.altScreen.searchPrevious\": true;\n\t\"tui.altScreen.searchClose\": true;\n\t\"tui.altScreen.top\": true;\n\t\"tui.altScreen.bottom\": true;\n}\n\nexport type Keybinding = keyof Keybindings;\n\nexport interface KeybindingDefinition {\n\tdefaultKeys: KeyId | KeyId[];\n\tdescription?: string;\n}\n\nexport type KeybindingDefinitions = Record<string, KeybindingDefinition>;\nexport type KeybindingsConfig = Record<string, KeyId | KeyId[] | undefined>;\n\nexport const TUI_KEYBINDINGS = {\n\t\"tui.editor.cursorUp\": { defaultKeys: \"up\", description: \"Move cursor up\" },\n\t\"tui.editor.cursorDown\": { defaultKeys: \"down\", description: \"Move cursor down\" },\n\t\"tui.editor.historyPrevious\": {\n\t\tdefaultKeys: [],\n\t\tdescription: \"Select previous prompt history entry\",\n\t},\n\t\"tui.editor.historyNext\": {\n\t\tdefaultKeys: [],\n\t\tdescription: \"Select next prompt history entry\",\n\t},\n\t\"tui.editor.cursorLeft\": {\n\t\tdefaultKeys: [\"left\", \"ctrl+b\"],\n\t\tdescription: \"Move cursor left\",\n\t},\n\t\"tui.editor.cursorRight\": {\n\t\tdefaultKeys: [\"right\", \"ctrl+f\"],\n\t\tdescription: \"Move cursor right\",\n\t},\n\t\"tui.editor.cursorWordLeft\": {\n\t\tdefaultKeys: [\"alt+left\", \"ctrl+left\", \"alt+b\"],\n\t\tdescription: \"Move cursor word left\",\n\t},\n\t\"tui.editor.cursorWordRight\": {\n\t\tdefaultKeys: [\"alt+right\", \"ctrl+right\", \"alt+f\"],\n\t\tdescription: \"Move cursor word right\",\n\t},\n\t\"tui.editor.cursorLineStart\": {\n\t\tdefaultKeys: [\"home\", \"ctrl+home\", \"ctrl+a\"],\n\t\tdescription: \"Move to line start\",\n\t},\n\t\"tui.editor.cursorLineEnd\": {\n\t\tdefaultKeys: [\"end\", \"ctrl+end\", \"ctrl+e\"],\n\t\tdescription: \"Move to line end\",\n\t},\n\t\"tui.editor.jumpForward\": {\n\t\tdefaultKeys: \"ctrl+]\",\n\t\tdescription: \"Jump forward to character\",\n\t},\n\t\"tui.editor.jumpBackward\": {\n\t\tdefaultKeys: \"ctrl+alt+]\",\n\t\tdescription: \"Jump backward to character\",\n\t},\n\t\"tui.editor.pageUp\": { defaultKeys: [\"pageUp\", \"ctrl+pageUp\"], description: \"Page up\" },\n\t\"tui.editor.pageDown\": { defaultKeys: [\"pageDown\", \"ctrl+pageDown\"], description: \"Page down\" },\n\t\"tui.editor.deleteCharBackward\": {\n\t\tdefaultKeys: \"backspace\",\n\t\tdescription: \"Delete character backward\",\n\t},\n\t\"tui.editor.deleteCharForward\": {\n\t\tdefaultKeys: [\"delete\", \"ctrl+d\"],\n\t\tdescription: \"Delete character forward\",\n\t},\n\t\"tui.editor.deleteWordBackward\": {\n\t\tdefaultKeys: [\"ctrl+w\", \"alt+backspace\"],\n\t\tdescription: \"Delete word backward\",\n\t},\n\t\"tui.editor.deleteWordForward\": {\n\t\tdefaultKeys: [\"alt+d\", \"alt+delete\"],\n\t\tdescription: \"Delete word forward\",\n\t},\n\t\"tui.editor.deleteToLineStart\": {\n\t\tdefaultKeys: \"ctrl+u\",\n\t\tdescription: \"Delete to line start\",\n\t},\n\t\"tui.editor.deleteToLineEnd\": {\n\t\tdefaultKeys: \"ctrl+k\",\n\t\tdescription: \"Delete to line end\",\n\t},\n\t\"tui.editor.yank\": { defaultKeys: \"ctrl+y\", description: \"Yank\" },\n\t\"tui.editor.yankPop\": { defaultKeys: \"alt+y\", description: \"Yank pop\" },\n\t\"tui.editor.undo\": { defaultKeys: \"ctrl+-\", description: \"Undo\" },\n\t\"tui.input.newLine\": { defaultKeys: [\"shift+enter\", \"ctrl+j\"], description: \"Insert newline\" },\n\t\"tui.input.submit\": { defaultKeys: \"enter\", description: \"Submit input\" },\n\t\"tui.input.tab\": { defaultKeys: \"tab\", description: \"Tab / autocomplete\" },\n\t\"tui.input.copy\": { defaultKeys: \"ctrl+c\", description: \"Copy selection\" },\n\t\"tui.select.up\": { defaultKeys: \"up\", description: \"Move selection up\" },\n\t\"tui.select.down\": { defaultKeys: \"down\", description: \"Move selection down\" },\n\t\"tui.select.pageUp\": { defaultKeys: \"pageUp\", description: \"Selection page up\" },\n\t\"tui.select.pageDown\": {\n\t\tdefaultKeys: \"pageDown\",\n\t\tdescription: \"Selection page down\",\n\t},\n\t\"tui.select.confirm\": { defaultKeys: \"enter\", description: \"Confirm selection\" },\n\t\"tui.select.cancel\": {\n\t\tdefaultKeys: [\"escape\", \"ctrl+c\"],\n\t\tdescription: \"Cancel selection\",\n\t},\n\t// These intentionally shadow the unmodified editor bindings in fullscreen mode.\n\t\"tui.altScreen.pageUp\": {\n\t\tdefaultKeys: \"pageUp\",\n\t\tdescription: \"Scroll viewport up one page\",\n\t},\n\t\"tui.altScreen.pageDown\": {\n\t\tdefaultKeys: \"pageDown\",\n\t\tdescription: \"Scroll viewport down one page\",\n\t},\n\t\"tui.altScreen.halfPageUp\": {\n\t\tdefaultKeys: [],\n\t\tdescription: \"Scroll viewport up half a page\",\n\t},\n\t\"tui.altScreen.halfPageDown\": {\n\t\tdefaultKeys: [],\n\t\tdescription: \"Scroll viewport down half a page\",\n\t},\n\t\"tui.altScreen.lineUp\": {\n\t\tdefaultKeys: [],\n\t\tdescription: \"Scroll viewport up one line\",\n\t},\n\t\"tui.altScreen.lineDown\": {\n\t\tdefaultKeys: [],\n\t\tdescription: \"Scroll viewport down one line\",\n\t},\n\t\"tui.altScreen.previousPrompt\": {\n\t\tdefaultKeys: \"ctrl+shift+up\",\n\t\tdescription: \"Jump to previous semantic prompt\",\n\t},\n\t\"tui.altScreen.nextPrompt\": {\n\t\tdefaultKeys: \"ctrl+shift+down\",\n\t\tdescription: \"Jump to next semantic prompt\",\n\t},\n\t\"tui.altScreen.search\": {\n\t\tdefaultKeys: \"ctrl+shift+f\",\n\t\tdescription: \"Search the primary scroll view\",\n\t},\n\t\"tui.altScreen.searchNext\": {\n\t\tdefaultKeys: [\"enter\", \"ctrl+g\"],\n\t\tdescription: \"Select the next search match\",\n\t},\n\t\"tui.altScreen.searchPrevious\": {\n\t\tdefaultKeys: [\"shift+enter\", \"ctrl+shift+g\"],\n\t\tdescription: \"Select the previous search match\",\n\t},\n\t\"tui.altScreen.searchClose\": {\n\t\tdefaultKeys: \"escape\",\n\t\tdescription: \"Close transcript search\",\n\t},\n\t\"tui.altScreen.top\": { defaultKeys: \"home\", description: \"Scroll viewport to top\" },\n\t\"tui.altScreen.bottom\": { defaultKeys: \"end\", description: \"Scroll viewport to bottom\" },\n} as const satisfies KeybindingDefinitions;\n\nexport interface KeybindingConflict {\n\tkey: KeyId;\n\tkeybindings: string[];\n}\n\nfunction normalizeKeys(keys: KeyId | KeyId[] | undefined): KeyId[] {\n\tif (keys === undefined) return [];\n\tconst keyList = Array.isArray(keys) ? keys : [keys];\n\tconst seen = new Set<KeyId>();\n\tconst result: KeyId[] = [];\n\tfor (const key of keyList) {\n\t\tif (!seen.has(key)) {\n\t\t\tseen.add(key);\n\t\t\tresult.push(key);\n\t\t}\n\t}\n\treturn result;\n}\n\nexport class KeybindingsManager {\n\tprivate definitions: KeybindingDefinitions;\n\tprivate userBindings: KeybindingsConfig;\n\tprivate keysById = new Map<Keybinding, KeyId[]>();\n\tprivate conflicts: KeybindingConflict[] = [];\n\n\tconstructor(definitions: KeybindingDefinitions, userBindings: KeybindingsConfig = {}) {\n\t\tthis.definitions = definitions;\n\t\tthis.userBindings = userBindings;\n\t\tthis.rebuild();\n\t}\n\n\tprivate rebuild(): void {\n\t\tthis.keysById.clear();\n\t\tthis.conflicts = [];\n\n\t\tconst userClaims = new Map<KeyId, Set<Keybinding>>();\n\t\tfor (const [keybinding, keys] of Object.entries(this.userBindings)) {\n\t\t\tif (!(keybinding in this.definitions)) continue;\n\t\t\tfor (const key of normalizeKeys(keys)) {\n\t\t\t\tconst claimants = userClaims.get(key) ?? new Set<Keybinding>();\n\t\t\t\tclaimants.add(keybinding as Keybinding);\n\t\t\t\tuserClaims.set(key, claimants);\n\t\t\t}\n\t\t}\n\n\t\tfor (const [key, keybindings] of userClaims) {\n\t\t\tif (keybindings.size > 1) {\n\t\t\t\tthis.conflicts.push({ key, keybindings: [...keybindings] });\n\t\t\t}\n\t\t}\n\n\t\tfor (const [id, definition] of Object.entries(this.definitions)) {\n\t\t\tconst userKeys = this.userBindings[id];\n\t\t\tconst keys = userKeys === undefined ? normalizeKeys(definition.defaultKeys) : normalizeKeys(userKeys);\n\t\t\tthis.keysById.set(id as Keybinding, keys);\n\t\t}\n\t}\n\n\tmatches(data: string, keybinding: Keybinding): boolean {\n\t\tconst keys = this.keysById.get(keybinding) ?? [];\n\t\tfor (const key of keys) {\n\t\t\tif (matchesKey(data, key)) return true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tgetKeys(keybinding: Keybinding): KeyId[] {\n\t\treturn [...(this.keysById.get(keybinding) ?? [])];\n\t}\n\n\tgetDefinition(keybinding: Keybinding): KeybindingDefinition {\n\t\treturn this.definitions[keybinding];\n\t}\n\n\tgetConflicts(): KeybindingConflict[] {\n\t\treturn this.conflicts.map((conflict) => ({ ...conflict, keybindings: [...conflict.keybindings] }));\n\t}\n\n\tsetUserBindings(userBindings: KeybindingsConfig): void {\n\t\tthis.userBindings = userBindings;\n\t\tthis.rebuild();\n\t}\n\n\tgetUserBindings(): KeybindingsConfig {\n\t\treturn { ...this.userBindings };\n\t}\n\n\tgetResolvedBindings(): KeybindingsConfig {\n\t\tconst resolved: KeybindingsConfig = {};\n\t\tfor (const id of Object.keys(this.definitions)) {\n\t\t\tconst keys = this.keysById.get(id as Keybinding) ?? [];\n\t\t\tresolved[id] = keys.length === 1 ? keys[0]! : [...keys];\n\t\t}\n\t\treturn resolved;\n\t}\n}\n\nlet globalKeybindings: KeybindingsManager | null = null;\n\nexport function setKeybindings(keybindings: KeybindingsManager): void {\n\tglobalKeybindings = keybindings;\n}\n\nexport function getKeybindings(): KeybindingsManager {\n\tif (!globalKeybindings) {\n\t\tglobalKeybindings = new KeybindingsManager(TUI_KEYBINDINGS);\n\t}\n\treturn globalKeybindings;\n}\n","// @ts-nocheck — vendored Pi source; checked upstream under Pi's own tsconfig.\nimport { visibleWidth } from \"./pi-tui-utils.ts\";\n\nconst SYMBOLS: Readonly<Record<string, string>> = {\n\talpha: \"α\",\n\tbeta: \"β\",\n\tgamma: \"γ\",\n\tdelta: \"δ\",\n\tepsilon: \"ϵ\",\n\tvarepsilon: \"ε\",\n\tzeta: \"ζ\",\n\teta: \"η\",\n\ttheta: \"θ\",\n\tvartheta: \"ϑ\",\n\tiota: \"ι\",\n\tkappa: \"κ\",\n\tvarkappa: \"ϰ\",\n\tlambda: \"λ\",\n\tmu: \"μ\",\n\tnu: \"ν\",\n\txi: \"ξ\",\n\tpi: \"π\",\n\tvarpi: \"ϖ\",\n\trho: \"ρ\",\n\tvarrho: \"ϱ\",\n\tsigma: \"σ\",\n\tvarsigma: \"ς\",\n\ttau: \"τ\",\n\tupsilon: \"υ\",\n\tphi: \"ϕ\",\n\tvarphi: \"φ\",\n\tchi: \"χ\",\n\tpsi: \"ψ\",\n\tomega: \"ω\",\n\tGamma: \"Γ\",\n\tDelta: \"Δ\",\n\tTheta: \"Θ\",\n\tLambda: \"Λ\",\n\tXi: \"Ξ\",\n\tPi: \"Π\",\n\tSigma: \"Σ\",\n\tUpsilon: \"Υ\",\n\tPhi: \"Φ\",\n\tPsi: \"Ψ\",\n\tOmega: \"Ω\",\n\tpm: \"±\",\n\tmp: \"∓\",\n\ttimes: \"×\",\n\tdiv: \"÷\",\n\tcdot: \"·\",\n\tast: \"∗\",\n\tstar: \"⋆\",\n\tcirc: \"∘\",\n\tbullet: \"•\",\n\toplus: \"⊕\",\n\tominus: \"⊖\",\n\totimes: \"⊗\",\n\toslash: \"⊘\",\n\todot: \"⊙\",\n\tbigcirc: \"○\",\n\tdagger: \"†\",\n\tddagger: \"‡\",\n\tamalg: \"⨿\",\n\tuplus: \"⊎\",\n\tsqcap: \"⊓\",\n\tsqcup: \"⊔\",\n\ttriangleleft: \"◁\",\n\ttriangleright: \"▷\",\n\twr: \"≀\",\n\tcap: \"∩\",\n\tcup: \"∪\",\n\tbigcap: \"⋂\",\n\tbigcup: \"⋃\",\n\tbigwedge: \"⋀\",\n\tbigvee: \"⋁\",\n\tbigsqcup: \"⨆\",\n\tbiguplus: \"⨄\",\n\tbigoplus: \"⨁\",\n\tbigotimes: \"⨂\",\n\tbigodot: \"⨀\",\n\tsetminus: \"∖\",\n\tin: \"∈\",\n\tnotin: \"∉\",\n\tni: \"∋\",\n\tsubset: \"⊂\",\n\tsupset: \"⊃\",\n\tsubseteq: \"⊆\",\n\tsupseteq: \"⊇\",\n\tsqsubset: \"⊏\",\n\tsqsupset: \"⊐\",\n\tsqsubseteq: \"⊑\",\n\tsqsupseteq: \"⊒\",\n\tprec: \"≺\",\n\tpreceq: \"≼\",\n\tsucc: \"≻\",\n\tsucceq: \"≽\",\n\tll: \"≪\",\n\tgg: \"≫\",\n\tle: \"≤\",\n\tleq: \"≤\",\n\tleqslant: \"≤\",\n\tge: \"≥\",\n\tgeq: \"≥\",\n\tgeqslant: \"≥\",\n\tne: \"≠\",\n\tneq: \"≠\",\n\tequiv: \"≡\",\n\tapprox: \"≈\",\n\tsim: \"∼\",\n\tsimeq: \"≃\",\n\tcong: \"≅\",\n\tasymp: \"≍\",\n\tdoteq: \"≐\",\n\tpropto: \"∝\",\n\tparallel: \"∥\",\n\tperp: \"⊥\",\n\tmid: \"∣\",\n\tvdash: \"⊢\",\n\tdashv: \"⊣\",\n\tmodels: \"⊨\",\n\tVdash: \"⊩\",\n\tVvdash: \"⊪\",\n\tnvdash: \"⊬\",\n\tnvDash: \"⊭\",\n\tforall: \"∀\",\n\texists: \"∃\",\n\tnexists: \"∄\",\n\tneg: \"¬\",\n\tland: \"∧\",\n\twedge: \"∧\",\n\tlor: \"∨\",\n\tvee: \"∨\",\n\tto: \"→\",\n\trightarrow: \"→\",\n\tlongrightarrow: \"→\",\n\tleftarrow: \"←\",\n\tlongleftarrow: \"←\",\n\tgets: \"←\",\n\tleftrightarrow: \"↔\",\n\tlongleftrightarrow: \"↔\",\n\thookleftarrow: \"↩\",\n\thookrightarrow: \"↪\",\n\ttwoheadleftarrow: \"↞\",\n\ttwoheadrightarrow: \"↠\",\n\tleftharpoonup: \"↼\",\n\tleftharpoondown: \"↽\",\n\trightharpoonup: \"⇀\",\n\trightharpoondown: \"⇁\",\n\trightleftharpoons: \"⇌\",\n\tleftrightharpoons: \"⇋\",\n\tnearrow: \"↗\",\n\tsearrow: \"↘\",\n\tswarrow: \"↙\",\n\tnwarrow: \"↖\",\n\trightsquigarrow: \"⇝\",\n\tleadsto: \"⇝\",\n\tRightarrow: \"⇒\",\n\tLongrightarrow: \"⇒\",\n\tLeftarrow: \"⇐\",\n\tLongleftarrow: \"⇐\",\n\tLeftrightarrow: \"⇔\",\n\tLongleftrightarrow: \"⇔\",\n\timplies: \"⇒\",\n\tiff: \"⇔\",\n\tmapsto: \"↦\",\n\tlongmapsto: \"↦\",\n\tuparrow: \"↑\",\n\tdownarrow: \"↓\",\n\tpartial: \"∂\",\n\tnabla: \"∇\",\n\tint: \"∫\",\n\tiint: \"∬\",\n\tiiint: \"∭\",\n\toint: \"∮\",\n\tsum: \"∑\",\n\tprod: \"∏\",\n\tcoprod: \"∐\",\n\tinfty: \"∞\",\n\temptyset: \"∅\",\n\tvarnothing: \"∅\",\n\tangle: \"∠\",\n\ttherefore: \"∴\",\n\tbecause: \"∵\",\n\taleph: \"ℵ\",\n\tbeth: \"ℶ\",\n\tgimel: \"ℷ\",\n\tdaleth: \"ℸ\",\n\ttop: \"⊤\",\n\tbot: \"⊥\",\n\ttriangle: \"△\",\n\tsquare: \"□\",\n\tlozenge: \"◊\",\n\tcheckmark: \"✓\",\n\tcomplement: \"∁\",\n\twp: \"℘\",\n\tprime: \"′\",\n\tldots: \"…\",\n\tdots: \"…\",\n\tcdots: \"⋯\",\n\tvdots: \"⋮\",\n\tddots: \"⋱\",\n\tell: \"ℓ\",\n\thbar: \"ℏ\",\n\tIm: \"ℑ\",\n\tRe: \"ℜ\",\n\tlangle: \"⟨\",\n\trangle: \"⟩\",\n\tvert: \"|\",\n\tlvert: \"|\",\n\trvert: \"|\",\n\tVert: \"‖\",\n\tlVert: \"‖\",\n\trVert: \"‖\",\n\tlbrace: \"{\",\n\trbrace: \"}\",\n\tbackslash: \"\\\\\",\n\tlfloor: \"⌊\",\n\trfloor: \"⌋\",\n\tlceil: \"⌈\",\n\trceil: \"⌉\",\n\tcolon: \":\",\n};\n\nconst NAMED_OPERATORS = new Set([\n\t\"arccos\",\n\t\"arcsin\",\n\t\"arctan\",\n\t\"arg\",\n\t\"cos\",\n\t\"cosh\",\n\t\"cot\",\n\t\"coth\",\n\t\"csc\",\n\t\"deg\",\n\t\"det\",\n\t\"dim\",\n\t\"exp\",\n\t\"gcd\",\n\t\"hom\",\n\t\"inf\",\n\t\"ker\",\n\t\"lg\",\n\t\"lim\",\n\t\"liminf\",\n\t\"limsup\",\n\t\"ln\",\n\t\"log\",\n\t\"max\",\n\t\"min\",\n\t\"Pr\",\n\t\"sec\",\n\t\"sin\",\n\t\"sinh\",\n\t\"sup\",\n\t\"tan\",\n\t\"tanh\",\n]);\n\nconst LIMIT_OPERATORS = new Set([\n\t\"argmax\",\n\t\"argmin\",\n\t\"inf\",\n\t\"injlim\",\n\t\"lim\",\n\t\"liminf\",\n\t\"limsup\",\n\t\"max\",\n\t\"min\",\n\t\"projlim\",\n\t\"sup\",\n]);\n\nconst DISPLAY_LIMIT_SYMBOLS = new Set([\n\t\"bigcap\",\n\t\"bigcup\",\n\t\"bigodot\",\n\t\"bigoplus\",\n\t\"bigotimes\",\n\t\"bigsqcup\",\n\t\"biguplus\",\n\t\"bigvee\",\n\t\"bigwedge\",\n\t\"coprod\",\n\t\"int\",\n\t\"iint\",\n\t\"iiint\",\n\t\"oint\",\n\t\"prod\",\n\t\"sum\",\n]);\n\nconst RELATION_COMMANDS = new Set([\n\t\"Leftarrow\",\n\t\"Leftrightarrow\",\n\t\"Longleftarrow\",\n\t\"Longleftrightarrow\",\n\t\"Longrightarrow\",\n\t\"Rightarrow\",\n\t\"Vdash\",\n\t\"Vvdash\",\n\t\"approx\",\n\t\"asymp\",\n\t\"cong\",\n\t\"dashv\",\n\t\"doteq\",\n\t\"downarrow\",\n\t\"equiv\",\n\t\"ge\",\n\t\"geq\",\n\t\"geqslant\",\n\t\"gets\",\n\t\"gg\",\n\t\"hookleftarrow\",\n\t\"hookrightarrow\",\n\t\"iff\",\n\t\"implies\",\n\t\"in\",\n\t\"leadsto\",\n\t\"le\",\n\t\"leftarrow\",\n\t\"leftharpoondown\",\n\t\"leftharpoonup\",\n\t\"leftrightarrow\",\n\t\"leftrightharpoons\",\n\t\"leq\",\n\t\"leqslant\",\n\t\"ll\",\n\t\"longleftarrow\",\n\t\"longleftrightarrow\",\n\t\"longmapsto\",\n\t\"longrightarrow\",\n\t\"mapsto\",\n\t\"mid\",\n\t\"models\",\n\t\"ne\",\n\t\"nearrow\",\n\t\"neq\",\n\t\"ni\",\n\t\"notin\",\n\t\"nvdash\",\n\t\"nvDash\",\n\t\"nwarrow\",\n\t\"parallel\",\n\t\"perp\",\n\t\"prec\",\n\t\"preceq\",\n\t\"propto\",\n\t\"rightharpoondown\",\n\t\"rightharpoonup\",\n\t\"rightleftharpoons\",\n\t\"rightarrow\",\n\t\"rightsquigarrow\",\n\t\"searrow\",\n\t\"sim\",\n\t\"simeq\",\n\t\"sqsubset\",\n\t\"sqsubseteq\",\n\t\"sqsupset\",\n\t\"sqsupseteq\",\n\t\"subset\",\n\t\"subseteq\",\n\t\"succ\",\n\t\"succeq\",\n\t\"supset\",\n\t\"supseteq\",\n\t\"swarrow\",\n\t\"to\",\n\t\"triangleleft\",\n\t\"triangleright\",\n\t\"twoheadleftarrow\",\n\t\"twoheadrightarrow\",\n\t\"uparrow\",\n\t\"vdash\",\n]);\n\nconst NEGATED_SYMBOLS: Readonly<Record<string, string>> = {\n\t\"<\": \"≮\",\n\t\">\": \"≯\",\n\t\"=\": \"≠\",\n\t\"∈\": \"∉\",\n\t\"∋\": \"∌\",\n\t\"∣\": \"∤\",\n\t\"∥\": \"∦\",\n\t\"∼\": \"≁\",\n\t\"≃\": \"≄\",\n\t\"≅\": \"≇\",\n\t\"≈\": \"≉\",\n\t\"≡\": \"≢\",\n\t\"≤\": \"≰\",\n\t\"≥\": \"≱\",\n\t\"≺\": \"⊀\",\n\t\"≻\": \"⊁\",\n\t\"⊂\": \"⊄\",\n\t\"⊃\": \"⊅\",\n\t\"⊆\": \"⊈\",\n\t\"⊇\": \"⊉\",\n\t\"⊢\": \"⊬\",\n\t\"⊨\": \"⊭\",\n\t\"↔\": \"↮\",\n\t\"←\": \"↚\",\n\t\"→\": \"↛\",\n\t\"⇒\": \"⇏\",\n\t\"⇐\": \"⇍\",\n\t\"⇔\": \"⇎\",\n\t\"≼\": \"⋠\",\n\t\"≽\": \"⋡\",\n};\n\nconst BLACKBOARD: Readonly<Record<string, string>> = {\n\tC: \"ℂ\",\n\tH: \"ℍ\",\n\tN: \"ℕ\",\n\tP: \"ℙ\",\n\tQ: \"ℚ\",\n\tR: \"ℝ\",\n\tZ: \"ℤ\",\n};\n\nconst SUPERSCRIPTS: Readonly<Record<string, string>> = {\n\t\"0\": \"⁰\",\n\t\"1\": \"¹\",\n\t\"2\": \"²\",\n\t\"3\": \"³\",\n\t\"4\": \"⁴\",\n\t\"5\": \"⁵\",\n\t\"6\": \"⁶\",\n\t\"7\": \"⁷\",\n\t\"8\": \"⁸\",\n\t\"9\": \"⁹\",\n\t\"+\": \"⁺\",\n\t\"-\": \"⁻\",\n\t\"=\": \"⁼\",\n\t\"(\": \"⁽\",\n\t\")\": \"⁾\",\n\ta: \"ᵃ\",\n\tb: \"ᵇ\",\n\tc: \"ᶜ\",\n\td: \"ᵈ\",\n\te: \"ᵉ\",\n\tf: \"ᶠ\",\n\tg: \"ᵍ\",\n\th: \"ʰ\",\n\ti: \"ⁱ\",\n\tj: \"ʲ\",\n\tk: \"ᵏ\",\n\tl: \"ˡ\",\n\tm: \"ᵐ\",\n\tn: \"ⁿ\",\n\to: \"ᵒ\",\n\tp: \"ᵖ\",\n\tr: \"ʳ\",\n\ts: \"ˢ\",\n\tt: \"ᵗ\",\n\tu: \"ᵘ\",\n\tv: \"ᵛ\",\n\tw: \"ʷ\",\n\tx: \"ˣ\",\n\ty: \"ʸ\",\n\tz: \"ᶻ\",\n};\n\nconst SUBSCRIPTS: Readonly<Record<string, string>> = {\n\t\"0\": \"₀\",\n\t\"1\": \"₁\",\n\t\"2\": \"₂\",\n\t\"3\": \"₃\",\n\t\"4\": \"₄\",\n\t\"5\": \"₅\",\n\t\"6\": \"₆\",\n\t\"7\": \"₇\",\n\t\"8\": \"₈\",\n\t\"9\": \"₉\",\n\t\"+\": \"₊\",\n\t\"-\": \"₋\",\n\t\"=\": \"₌\",\n\t\"(\": \"₍\",\n\t\")\": \"₎\",\n\ta: \"ₐ\",\n\te: \"ₑ\",\n\th: \"ₕ\",\n\ti: \"ᵢ\",\n\tj: \"ⱼ\",\n\tk: \"ₖ\",\n\tl: \"ₗ\",\n\tm: \"ₘ\",\n\tn: \"ₙ\",\n\to: \"ₒ\",\n\tp: \"ₚ\",\n\tr: \"ᵣ\",\n\ts: \"ₛ\",\n\tt: \"ₜ\",\n\tu: \"ᵤ\",\n\tv: \"ᵥ\",\n\tx: \"ₓ\",\n};\n\nconst SPACING_COMMANDS = new Set([\n\t\",\",\n\t\":\",\n\t\";\",\n\t\" \",\n\t\">\",\n\t\"enspace\",\n\t\"enskip\",\n\t\"medspace\",\n\t\"quad\",\n\t\"qquad\",\n\t\"thickspace\",\n\t\"thinspace\",\n]);\nconst NEGATIVE_SPACING_COMMANDS = new Set([\"!\", \"negmedspace\", \"negthickspace\", \"negthinspace\"]);\nconst NEGATIVE_SPACE = \"\\u0000\";\nconst IGNORED_COMMANDS = new Set([\n\t\"displaystyle\",\n\t\"limits\",\n\t\"nolimits\",\n\t\"scriptstyle\",\n\t\"scriptscriptstyle\",\n\t\"textstyle\",\n]);\nconst SIZE_COMMANDS = new Set([\n\t\"big\",\n\t\"Big\",\n\t\"bigg\",\n\t\"Bigg\",\n\t\"bigl\",\n\t\"Bigl\",\n\t\"biggl\",\n\t\"Biggl\",\n\t\"bigr\",\n\t\"Bigr\",\n\t\"biggr\",\n\t\"Biggr\",\n]);\nconst PLAIN_WRAPPERS = new Set([\n\t\"emph\",\n\t\"mathcal\",\n\t\"mathbf\",\n\t\"mathfrak\",\n\t\"mathit\",\n\t\"mathrm\",\n\t\"mathnormal\",\n\t\"mathscr\",\n\t\"mathsf\",\n\t\"mathtt\",\n\t\"mathup\",\n\t\"mbox\",\n\t\"overbrace\",\n\t\"pmb\",\n\t\"smash\",\n\t\"substack\",\n\t\"text\",\n\t\"textbf\",\n\t\"textit\",\n\t\"textmd\",\n\t\"textnormal\",\n\t\"textrm\",\n\t\"textsc\",\n\t\"textsf\",\n\t\"textsl\",\n\t\"texttt\",\n\t\"textup\",\n\t\"underbrace\",\n\t\"bm\",\n\t\"boldsymbol\",\n]);\nconst ACCENTS: Readonly<Record<string, string>> = {\n\tacute: \"\\u0301\",\n\tbar: \"\\u0305\",\n\tbreve: \"\\u0306\",\n\tcheck: \"\\u030c\",\n\tddot: \"\\u0308\",\n\tdot: \"\\u0307\",\n\tgrave: \"\\u0300\",\n\that: \"\\u0302\",\n\tmathring: \"\\u030a\",\n\toverleftarrow: \"\\u20d6\",\n\toverleftrightarrow: \"\\u20e1\",\n\toverline: \"\\u0305\",\n\toverrightarrow: \"\\u20d7\",\n\ttilde: \"\\u0303\",\n\tunderline: \"\\u0332\",\n\tvec: \"\\u20d7\",\n\twidehat: \"\\u0302\",\n\twidetilde: \"\\u0303\",\n};\n\nfunction replaceCharacters(value: string, replacements: Readonly<Record<string, string>>): string | undefined {\n\tlet result = \"\";\n\tfor (const character of value) {\n\t\tconst replacement = replacements[character];\n\t\tif (replacement === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tresult += replacement;\n\t}\n\treturn result;\n}\n\nfunction formatScript(value: string, kind: \"sub\" | \"sup\"): string {\n\tvalue = value.trim();\n\tconst replacements = kind === \"sub\" ? SUBSCRIPTS : SUPERSCRIPTS;\n\tconst unicode = replaceCharacters(value.replace(/\\s*([=+-])\\s*/g, \"$1\"), replacements);\n\tif (unicode !== undefined) {\n\t\treturn unicode;\n\t}\n\n\tconst prefix = kind === \"sub\" ? \"_\" : \"^\";\n\tif (Array.from(value).length === 1 || (kind === \"sub\" && /^[A-Za-z]+$/.test(value))) {\n\t\treturn `${prefix}${value}`;\n\t}\n\treturn `${prefix}(${value})`;\n}\n\nfunction formatFraction(numerator: string, denominator: string): string {\n\tnumerator = numerator.trim();\n\tdenominator = denominator.trim();\n\tconst simpleNumerator = /^[\\p{L}\\p{N}.]+$/u.test(numerator);\n\tconst simpleDenominator = /^[\\p{N}.]+$/u.test(denominator) || Array.from(denominator).length === 1;\n\treturn `${simpleNumerator ? numerator : `(${numerator})`}/${simpleDenominator ? denominator : `(${denominator})`}`;\n}\n\nfunction formatRoot(value: string, symbol = \"√\"): string {\n\tvalue = value.trim();\n\treturn /^[\\p{L}\\p{N}.]+$/u.test(value) ? `${symbol}${value}` : `${symbol}(${value})`;\n}\n\nconst NAMED_OPERATOR_START = \"\\u{f0004}\";\nconst NAMED_OPERATOR_END = \"\\u{f0005}\";\nconst NAMED_OPERATOR_LEFT_SPACING_PATTERN = /(?<=[\\p{L}\\p{N})\\]}\\u{f0001}])\\u{f0004}/gu;\nconst NAMED_OPERATOR_RIGHT_SPACING_PATTERN = /\\u{f0005}(?=[\\p{L}\\p{N}√\\u{f0000}])/gu;\n\nfunction normalizeOutput(value: string): string {\n\treturn value\n\t\t.replace(NAMED_OPERATOR_LEFT_SPACING_PATTERN, \" \")\n\t\t.replaceAll(NAMED_OPERATOR_START, \"\")\n\t\t.replace(NAMED_OPERATOR_RIGHT_SPACING_PATTERN, \" \")\n\t\t.replaceAll(NAMED_OPERATOR_END, \"\")\n\t\t.split(\"\\n\")\n\t\t.map((line) => line.replace(/[ \\t]+/g, \" \").trim())\n\t\t.filter((line, index, lines) => line.length > 0 || (index > 0 && index < lines.length - 1))\n\t\t.join(\"\\n\")\n\t\t.trim();\n}\n\ninterface FractionNode {\n\ttype: \"fraction\";\n\tnumerator: string;\n\tdenominator: string;\n}\n\ninterface OperatorNode {\n\ttype: \"operator\";\n\toperator: string;\n\tlower?: string;\n\tupper?: string;\n}\n\ninterface MatrixNode {\n\ttype: \"matrix\";\n\tlines: string[];\n\tbaseline: number;\n}\n\ntype LayoutNode = FractionNode | OperatorNode | MatrixNode;\n\ninterface Layout {\n\tlines: string[];\n\twidth: number;\n\tbaseline: number;\n}\n\nconst LAYOUT_MARKER_START = \"\\u{f0000}\";\nconst LAYOUT_MARKER_END = \"\\u{f0001}\";\nconst LAYOUT_MARKER_PATTERN = /\\u{f0000}(\\d+)\\u{f0001}/gu;\nconst TRAILING_LAYOUT_MARKER_PATTERN = /\\u{f0000}(\\d+)\\u{f0001}$/u;\nconst PROTECTED_SPACE = \"\\u{f0002}\";\n\nfunction padLayoutLine(line: string, width: number, centered = false): string {\n\tconst padding = Math.max(0, width - visibleWidth(line));\n\tconst left = centered ? Math.floor(padding / 2) : 0;\n\treturn `${\" \".repeat(left)}${line}${\" \".repeat(padding - left)}`;\n}\n\nfunction joinLayouts(layouts: readonly Layout[]): Layout {\n\tif (layouts.length === 0) {\n\t\treturn { lines: [\"\"], width: 0, baseline: 0 };\n\t}\n\tconst baseline = Math.max(...layouts.map((layout) => layout.baseline));\n\tconst below = Math.max(...layouts.map((layout) => layout.lines.length - layout.baseline - 1));\n\tconst lines: string[] = [];\n\tfor (let row = 0; row <= baseline + below; row++) {\n\t\tlet line = \"\";\n\t\tfor (const layout of layouts) {\n\t\t\tconst sourceRow = row - baseline + layout.baseline;\n\t\t\tline +=\n\t\t\t\tsourceRow >= 0 && sourceRow < layout.lines.length\n\t\t\t\t\t? padLayoutLine(layout.lines[sourceRow] ?? \"\", layout.width)\n\t\t\t\t\t: \" \".repeat(layout.width);\n\t\t}\n\t\tlines.push(line.trimEnd());\n\t}\n\treturn {\n\t\tlines,\n\t\twidth: layouts.reduce((width, layout) => width + layout.width, 0),\n\t\tbaseline,\n\t};\n}\n\nfunction renderLayout(source: string, nodes: readonly LayoutNode[]): Layout {\n\tconst renderedLines: string[] = [];\n\tlet firstBaseline = 0;\n\tfor (const sourceLine of source.split(\"\\n\")) {\n\t\tconst layouts: Layout[] = [];\n\t\tlet position = 0;\n\t\tlet previousNode: LayoutNode | undefined;\n\t\tfor (const match of sourceLine.matchAll(LAYOUT_MARKER_PATTERN)) {\n\t\t\tconst index = match.index;\n\t\t\tconst node = nodes[Number(match[1])];\n\t\t\tif (!node) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (index > position) {\n\t\t\t\tconst sliced = sourceLine.slice(position, index);\n\t\t\t\tconst trimmed = (previousNode ? sliced.trimStart() : sliced).trimEnd();\n\t\t\t\tconst preserveLeadingSpace = previousNode?.type === \"matrix\" && /^\\s/.test(sliced);\n\t\t\t\tconst preserveTrailingSpace = node.type === \"matrix\" && /\\s$/.test(sliced);\n\t\t\t\tconst text = trimmed\n\t\t\t\t\t? `${preserveLeadingSpace ? \" \" : \"\"}${trimmed}${preserveTrailingSpace ? \" \" : \"\"}`\n\t\t\t\t\t: preserveLeadingSpace || preserveTrailingSpace\n\t\t\t\t\t\t? \" \"\n\t\t\t\t\t\t: \"\";\n\t\t\t\tlayouts.push({ lines: [text], width: visibleWidth(text), baseline: 0 });\n\t\t\t}\n\t\t\tif (node.type === \"fraction\") {\n\t\t\t\tconst numerator = renderLayout(node.numerator, nodes);\n\t\t\t\tconst denominator = renderLayout(node.denominator, nodes);\n\t\t\t\tconst contentWidth = Math.max(numerator.width, denominator.width, 1);\n\t\t\t\tconst width = contentWidth + 2;\n\t\t\t\tlayouts.push({\n\t\t\t\t\tlines: [\n\t\t\t\t\t\t...numerator.lines.map((line) => padLayoutLine(line, width, true)),\n\t\t\t\t\t\t` ${\"─\".repeat(contentWidth)} `,\n\t\t\t\t\t\t...denominator.lines.map((line) => padLayoutLine(line, width, true)),\n\t\t\t\t\t],\n\t\t\t\t\twidth,\n\t\t\t\t\tbaseline: numerator.lines.length,\n\t\t\t\t});\n\t\t\t} else if (node.type === \"operator\") {\n\t\t\t\tconst contentWidth = Math.max(\n\t\t\t\t\tvisibleWidth(node.operator),\n\t\t\t\t\tnode.lower === undefined ? 0 : visibleWidth(node.lower),\n\t\t\t\t\tnode.upper === undefined ? 0 : visibleWidth(node.upper),\n\t\t\t\t);\n\t\t\t\tconst lines: string[] = [];\n\t\t\t\tif (node.upper !== undefined) {\n\t\t\t\t\tlines.push(`${padLayoutLine(node.upper, contentWidth, true)} `);\n\t\t\t\t}\n\t\t\t\tlines.push(`${padLayoutLine(node.operator, contentWidth, true)} `);\n\t\t\t\tif (node.lower !== undefined) {\n\t\t\t\t\tlines.push(`${padLayoutLine(node.lower, contentWidth, true)} `);\n\t\t\t\t}\n\t\t\t\tlayouts.push({\n\t\t\t\t\tlines,\n\t\t\t\t\twidth: contentWidth + 1,\n\t\t\t\t\tbaseline: node.upper === undefined ? 0 : 1,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst width = Math.max(0, ...node.lines.map((line) => visibleWidth(line)));\n\t\t\t\tlayouts.push({\n\t\t\t\t\tlines: node.lines.map((line) => padLayoutLine(line, width)),\n\t\t\t\t\twidth,\n\t\t\t\t\tbaseline: node.baseline,\n\t\t\t\t});\n\t\t\t}\n\t\t\tposition = index + match[0].length;\n\t\t\tpreviousNode = node;\n\t\t}\n\t\tif (position < sourceLine.length) {\n\t\t\tconst sliced = sourceLine.slice(position);\n\t\t\tconst trimmed = previousNode ? sliced.trimStart() : sliced;\n\t\t\tconst text = previousNode?.type === \"matrix\" && /^\\s/.test(sliced) ? ` ${trimmed}` : trimmed;\n\t\t\tlayouts.push({ lines: [text], width: visibleWidth(text), baseline: 0 });\n\t\t}\n\t\tconst lineLayout = joinLayouts(layouts);\n\t\tif (renderedLines.length === 0) {\n\t\t\tfirstBaseline = lineLayout.baseline;\n\t\t}\n\t\trenderedLines.push(...lineLayout.lines);\n\t}\n\treturn {\n\t\tlines: renderedLines,\n\t\twidth: Math.max(0, ...renderedLines.map((line) => visibleWidth(line))),\n\t\tbaseline: firstBaseline,\n\t};\n}\n\nclass LatexParser {\n\tprivate readonly source: string;\n\tprivate readonly layoutNodes: LayoutNode[];\n\tprivate readonly display: boolean;\n\tprivate position = 0;\n\tprivate supported = true;\n\tprivate stackFractions = true;\n\n\tconstructor(source: string, layoutNodes: LayoutNode[], display: boolean) {\n\t\tthis.source = source;\n\t\tthis.layoutNodes = layoutNodes;\n\t\tthis.display = display;\n\t}\n\n\trender(): string | undefined {\n\t\tconst rendered = this.parseSequence();\n\t\tif (!this.supported || this.position !== this.source.length) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn normalizeOutput(rendered);\n\t}\n\n\tprivate parseSequence(endCharacter?: string): string {\n\t\tlet result = \"\";\n\t\twhile (this.position < this.source.length) {\n\t\t\tconst character = this.source[this.position];\n\t\t\tif (endCharacter && character === endCharacter) {\n\t\t\t\tthis.position++;\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tif (character === \"}\") {\n\t\t\t\tthis.supported = false;\n\t\t\t\treturn result;\n\t\t\t}\n\n\t\t\tif (character === \"{\") {\n\t\t\t\tthis.position++;\n\t\t\t\tresult += this.parseSequence(\"}\");\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (character === \"\\\\\") {\n\t\t\t\tconst command = this.parseCommand();\n\t\t\t\tif (command === NEGATIVE_SPACE) {\n\t\t\t\t\tresult = result.trimEnd();\n\t\t\t\t\tif (result.endsWith(NAMED_OPERATOR_END)) {\n\t\t\t\t\t\tresult = result.slice(0, -NAMED_OPERATOR_END.length);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tresult += command;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (character === \"^\" || character === \"_\") {\n\t\t\t\tthis.position++;\n\t\t\t\tresult = result.trimEnd();\n\t\t\t\tconst script = formatScript(this.parseRequiredArgument(false), character === \"_\" ? \"sub\" : \"sup\");\n\t\t\t\tif (result.endsWith(NAMED_OPERATOR_END)) {\n\t\t\t\t\tresult = `${result.slice(0, -NAMED_OPERATOR_END.length)}${script}${NAMED_OPERATOR_END}`;\n\t\t\t\t} else {\n\t\t\t\t\tresult += script;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (/\\s/.test(character)) {\n\t\t\t\tresult += this.parseWhitespace();\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (character === \"=\" || character === \"<\" || character === \">\") {\n\t\t\t\tresult = `${result.trimEnd()} ${character} `;\n\t\t\t\tthis.position++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (character === \"&\") {\n\t\t\t\tthis.position++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (character === \"~\") {\n\t\t\t\tthis.position++;\n\t\t\t\tresult += \" \";\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (character === \".\") {\n\t\t\t\tconst marker = TRAILING_LAYOUT_MARKER_PATTERN.exec(result);\n\t\t\t\tconst node = marker ? this.layoutNodes[Number(marker[1])] : undefined;\n\t\t\t\tif (node?.type === \"matrix\") {\n\t\t\t\t\tconst lastLine = node.lines.length - 1;\n\t\t\t\t\tnode.lines[lastLine] = `${node.lines[lastLine] ?? \"\"}${character}`;\n\t\t\t\t\tthis.position++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresult += character;\n\t\t\tthis.position++;\n\t\t}\n\n\t\tif (endCharacter) {\n\t\t\tthis.supported = false;\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate parseWhitespace(): string {\n\t\twhile (this.position < this.source.length && /\\s/.test(this.source[this.position] ?? \"\")) {\n\t\t\tthis.position++;\n\t\t}\n\t\treturn \" \";\n\t}\n\n\tprivate parseCommand(): string {\n\t\tthis.position++;\n\t\tif (this.position >= this.source.length) {\n\t\t\tthis.supported = false;\n\t\t\treturn \"\";\n\t\t}\n\n\t\tlet command = \"\";\n\t\tconst first = this.source[this.position] ?? \"\";\n\t\tif (first === \"\\n\" || first === \"\\r\") {\n\t\t\tthis.position++;\n\t\t\tif (first === \"\\r\" && this.source[this.position] === \"\\n\") {\n\t\t\t\tthis.position++;\n\t\t\t}\n\t\t\treturn \" \";\n\t\t}\n\t\tif (/[A-Za-z]/.test(first)) {\n\t\t\tconst start = this.position;\n\t\t\twhile (this.position < this.source.length && /[A-Za-z]/.test(this.source[this.position] ?? \"\")) {\n\t\t\t\tthis.position++;\n\t\t\t}\n\t\t\tcommand = this.source.slice(start, this.position);\n\t\t} else {\n\t\t\tcommand = first;\n\t\t\tthis.position++;\n\t\t}\n\n\t\tif (command === \"\\\\\") {\n\t\t\treturn \"\\n\";\n\t\t}\n\t\tif (SPACING_COMMANDS.has(command)) {\n\t\t\treturn \" \";\n\t\t}\n\t\tif (NEGATIVE_SPACING_COMMANDS.has(command)) {\n\t\t\treturn NEGATIVE_SPACE;\n\t\t}\n\t\tif (IGNORED_COMMANDS.has(command)) {\n\t\t\treturn \"\";\n\t\t}\n\t\tif (\n\t\t\tcommand === \"{\" ||\n\t\t\tcommand === \"}\" ||\n\t\t\tcommand === \"$\" ||\n\t\t\tcommand === \"%\" ||\n\t\t\tcommand === \"#\" ||\n\t\t\tcommand === \"_\" ||\n\t\t\tcommand === \"&\"\n\t\t) {\n\t\t\treturn command;\n\t\t}\n\t\tif (command === \"|\") {\n\t\t\treturn \"‖\";\n\t\t}\n\t\tif (command === \"not\") {\n\t\t\tconst value = this.parseRequiredArgument(false).trim();\n\t\t\tconst negated = NEGATED_SYMBOLS[value];\n\t\t\tif (negated !== undefined) {\n\t\t\t\treturn ` ${negated} `;\n\t\t\t}\n\t\t\tconst characters = Array.from(value);\n\t\t\tif (characters.length === 0) {\n\t\t\t\tthis.supported = false;\n\t\t\t\treturn \"\";\n\t\t\t}\n\t\t\treturn ` ${characters[0]}\\u0338${characters.slice(1).join(\"\")} `;\n\t\t}\n\t\tif (LIMIT_OPERATORS.has(command)) {\n\t\t\treturn this.parseOperator(command, \"bracket\", true, true);\n\t\t}\n\n\t\tconst symbol = SYMBOLS[command];\n\t\tif (symbol !== undefined) {\n\t\t\tif (DISPLAY_LIMIT_SYMBOLS.has(command)) {\n\t\t\t\treturn this.parseOperator(symbol, \"script\", true);\n\t\t\t}\n\t\t\treturn command === \"cdot\" || command === \"times\" || RELATION_COMMANDS.has(command) ? ` ${symbol} ` : symbol;\n\t\t}\n\t\tif (NAMED_OPERATORS.has(command)) {\n\t\t\treturn `${NAMED_OPERATOR_START}${command}${NAMED_OPERATOR_END}`;\n\t\t}\n\t\tif (SIZE_COMMANDS.has(command)) {\n\t\t\treturn \"\";\n\t\t}\n\t\tif (command === \"left\" || command === \"middle\" || command === \"right\") {\n\t\t\tif (this.source[this.position] === \".\") {\n\t\t\t\tthis.position++;\n\t\t\t}\n\t\t\treturn \"\";\n\t\t}\n\t\tif (command === \"frac\" || command === \"dfrac\" || command === \"tfrac\") {\n\t\t\tconst shouldStack = this.display && this.stackFractions && command !== \"tfrac\";\n\t\t\tconst numerator = this.parseRequiredArgument(!shouldStack);\n\t\t\tconst denominator = this.parseRequiredArgument(!shouldStack);\n\t\t\tif (shouldStack) {\n\t\t\t\tconst index =\n\t\t\t\t\tthis.layoutNodes.push({\n\t\t\t\t\t\ttype: \"fraction\",\n\t\t\t\t\t\tnumerator: normalizeOutput(numerator),\n\t\t\t\t\t\tdenominator: normalizeOutput(denominator),\n\t\t\t\t\t}) - 1;\n\t\t\t\treturn `${LAYOUT_MARKER_START}${index}${LAYOUT_MARKER_END}`;\n\t\t\t}\n\t\t\treturn formatFraction(numerator, denominator);\n\t\t}\n\t\tif (command === \"sqrt\") {\n\t\t\tconst degree = this.parseOptionalArgument()?.trim();\n\t\t\tconst value = this.parseRequiredArgument();\n\t\t\tif (degree === undefined || degree === \"2\") {\n\t\t\t\treturn formatRoot(value);\n\t\t\t}\n\t\t\tif (degree === \"3\") {\n\t\t\t\treturn formatRoot(value, \"∛\");\n\t\t\t}\n\t\t\tif (degree === \"4\") {\n\t\t\t\treturn formatRoot(value, \"∜\");\n\t\t\t}\n\t\t\treturn `${formatScript(degree, \"sup\")}${formatRoot(value)}`;\n\t\t}\n\t\tif (command === \"boxed\" || command === \"fbox\") {\n\t\t\treturn `[${this.parseRequiredArgument().trim()}]`;\n\t\t}\n\t\tif (command === \"binom\" || command === \"dbinom\" || command === \"tbinom\") {\n\t\t\treturn `(${this.parseRequiredArgument()} choose ${this.parseRequiredArgument()})`;\n\t\t}\n\t\tconst accent = ACCENTS[command];\n\t\tif (accent !== undefined) {\n\t\t\tconst value = this.parseRequiredArgument();\n\t\t\treturn Array.from(value).length === 1 ? `${value}${accent}` : `${command}(${value})`;\n\t\t}\n\t\tif (command === \"mathbb\") {\n\t\t\tconst value = this.parseRequiredArgument();\n\t\t\treturn Array.from(value, (character) => BLACKBOARD[character] ?? character).join(\"\");\n\t\t}\n\t\tif (command === \"operatorname\") {\n\t\t\tconst starred = this.source[this.position] === \"*\";\n\t\t\tif (starred) {\n\t\t\t\tthis.position++;\n\t\t\t}\n\t\t\tconst operator = normalizeOutput(this.parseRequiredArgument()).trim();\n\t\t\treturn this.parseOperator(operator, \"bracket\", starred, true);\n\t\t}\n\t\tif (command === \"mod\" || command === \"bmod\") {\n\t\t\treturn \" mod \";\n\t\t}\n\t\tif (command === \"pmod\" || command === \"pod\") {\n\t\t\tconst value = this.parseRequiredArgument().trim();\n\t\t\treturn command === \"pmod\" ? ` (mod ${value})` : ` (${value})`;\n\t\t}\n\t\tif (command === \"overset\" || command === \"stackrel\") {\n\t\t\tconst upper = this.parseRequiredArgument();\n\t\t\tconst value = this.parseRequiredArgument().trim();\n\t\t\treturn `${value}${formatScript(upper, \"sup\")}`;\n\t\t}\n\t\tif (command === \"underset\") {\n\t\t\tconst lower = this.parseRequiredArgument();\n\t\t\tconst value = this.parseRequiredArgument().trim();\n\t\t\treturn `${value}${formatScript(lower, \"sub\")}`;\n\t\t}\n\t\tif (PLAIN_WRAPPERS.has(command)) {\n\t\t\tconst value = this.parseRequiredArgument();\n\t\t\treturn command.startsWith(\"text\") || command === \"mbox\" ? value : value.trim();\n\t\t}\n\t\tif (command === \"begin\") {\n\t\t\treturn this.parseEnvironment();\n\t\t}\n\t\tif (command === \"end\") {\n\t\t\tthis.supported = false;\n\t\t\treturn \"\";\n\t\t}\n\n\t\tthis.supported = false;\n\t\treturn `\\\\${command}`;\n\t}\n\n\tprivate parseOperator(\n\t\toperator: string,\n\t\tinlineLowerStyle: \"bracket\" | \"script\",\n\t\tdisplayLimits: boolean,\n\t\tspaced = false,\n\t): string {\n\t\tlet useDisplayLimits = displayLimits;\n\t\tlet modifierPosition = this.position;\n\t\twhile (modifierPosition < this.source.length && /[ \\t]/.test(this.source[modifierPosition] ?? \"\")) {\n\t\t\tmodifierPosition++;\n\t\t}\n\t\tconst modifier = /^\\\\(limits|nolimits)(?![A-Za-z])/.exec(this.source.slice(modifierPosition));\n\t\tif (modifier) {\n\t\t\tuseDisplayLimits = modifier[1] === \"limits\";\n\t\t\tthis.position = modifierPosition + modifier[0].length;\n\t\t}\n\n\t\tlet lower: string | undefined;\n\t\tlet upper: string | undefined;\n\t\twhile (true) {\n\t\t\tlet scriptPosition = this.position;\n\t\t\twhile (scriptPosition < this.source.length && /[ \\t]/.test(this.source[scriptPosition] ?? \"\")) {\n\t\t\t\tscriptPosition++;\n\t\t\t}\n\t\t\tconst kind = this.source[scriptPosition];\n\t\t\tif (kind !== \"_\" && kind !== \"^\") {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthis.position = scriptPosition + 1;\n\t\t\tconst value = normalizeOutput(this.parseRequiredArgument(false)).replaceAll(\" \", \"\");\n\t\t\tif (kind === \"_\") {\n\t\t\t\tif (lower !== undefined) {\n\t\t\t\t\tthis.supported = false;\n\t\t\t\t}\n\t\t\t\tlower = value;\n\t\t\t} else {\n\t\t\t\tif (upper !== undefined) {\n\t\t\t\t\tthis.supported = false;\n\t\t\t\t}\n\t\t\t\tupper = value;\n\t\t\t}\n\t\t}\n\n\t\tif (this.display && useDisplayLimits && (lower !== undefined || upper !== undefined)) {\n\t\t\tconst index = this.layoutNodes.push({ type: \"operator\", operator, lower, upper }) - 1;\n\t\t\treturn `${LAYOUT_MARKER_START}${index}${LAYOUT_MARKER_END}`;\n\t\t}\n\n\t\tlet rendered = operator;\n\t\tif (lower !== undefined) {\n\t\t\trendered += inlineLowerStyle === \"bracket\" ? `[${lower}]` : formatScript(lower, \"sub\");\n\t\t}\n\t\tif (upper !== undefined) {\n\t\t\trendered += formatScript(upper, \"sup\");\n\t\t}\n\t\treturn spaced ? ` ${rendered} ` : rendered;\n\t}\n\n\tprivate parseRequiredArgument(stackFractions = true): string {\n\t\tconst previousStackFractions = this.stackFractions;\n\t\tthis.stackFractions = previousStackFractions && stackFractions;\n\t\tconst value = this.parseRequiredArgumentValue();\n\t\tthis.stackFractions = previousStackFractions;\n\t\treturn value;\n\t}\n\n\tprivate parseRequiredArgumentValue(): string {\n\t\twhile (this.position < this.source.length && /\\s/.test(this.source[this.position] ?? \"\")) {\n\t\t\tthis.position++;\n\t\t}\n\t\tif (this.position >= this.source.length) {\n\t\t\tthis.supported = false;\n\t\t\treturn \"\";\n\t\t}\n\t\tif (this.source[this.position] === \"{\") {\n\t\t\tthis.position++;\n\t\t\treturn this.parseSequence(\"}\");\n\t\t}\n\t\tif (this.source[this.position] === \"\\\\\") {\n\t\t\treturn this.parseCommand();\n\t\t}\n\t\tconst value = this.source[this.position] ?? \"\";\n\t\tthis.position++;\n\t\treturn value;\n\t}\n\n\tprivate parseOptionalArgument(): string | undefined {\n\t\twhile (this.position < this.source.length && /[ \\t]/.test(this.source[this.position] ?? \"\")) {\n\t\t\tthis.position++;\n\t\t}\n\t\tif (this.source[this.position] !== \"[\") {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst end = this.source.indexOf(\"]\", this.position + 1);\n\t\tif (end < 0) {\n\t\t\tthis.supported = false;\n\t\t\treturn undefined;\n\t\t}\n\t\tconst value = this.source.slice(this.position + 1, end);\n\t\tthis.position = end + 1;\n\t\treturn this.renderNested(value);\n\t}\n\n\tprivate readRawGroup(): string | undefined {\n\t\twhile (this.position < this.source.length && /[ \\t]/.test(this.source[this.position] ?? \"\")) {\n\t\t\tthis.position++;\n\t\t}\n\t\tif (this.source[this.position] !== \"{\") {\n\t\t\tthis.supported = false;\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst start = ++this.position;\n\t\tlet depth = 1;\n\t\twhile (this.position < this.source.length) {\n\t\t\tconst character = this.source[this.position];\n\t\t\tif (character === \"\\\\\") {\n\t\t\t\tthis.position += 2;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (character === \"{\") depth++;\n\t\t\tif (character === \"}\") depth--;\n\t\t\tif (depth === 0) {\n\t\t\t\tconst value = this.source.slice(start, this.position);\n\t\t\t\tthis.position++;\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tthis.position++;\n\t\t}\n\t\tthis.supported = false;\n\t\treturn undefined;\n\t}\n\n\tprivate splitEnvironmentRows(body: string): string[] {\n\t\treturn body.split(/\\\\\\\\(?:\\[[^\\]\\n]*\\])?/);\n\t}\n\n\tprivate parseEnvironment(): string {\n\t\tconst environment = this.readRawGroup();\n\t\tif (!environment) {\n\t\t\treturn \"\";\n\t\t}\n\t\tconst endMarker = `\\\\end{${environment}}`;\n\t\tconst end = this.source.indexOf(endMarker, this.position);\n\t\tif (end < 0) {\n\t\t\tthis.supported = false;\n\t\t\treturn \"\";\n\t\t}\n\t\tconst body = this.source.slice(this.position, end);\n\t\tthis.position = end + endMarker.length;\n\n\t\tif (environment === \"equation\" || environment === \"equation*\" || environment === \"displaymath\") {\n\t\t\treturn this.renderNested(body).trim();\n\t\t}\n\n\t\tif (\n\t\t\tenvironment === \"aligned\" ||\n\t\t\tenvironment === \"align\" ||\n\t\t\tenvironment === \"align*\" ||\n\t\t\tenvironment === \"alignedat\" ||\n\t\t\tenvironment === \"alignat\" ||\n\t\t\tenvironment === \"alignat*\" ||\n\t\t\tenvironment === \"gather\" ||\n\t\t\tenvironment === \"gathered\" ||\n\t\t\tenvironment === \"multline\" ||\n\t\t\tenvironment === \"multline*\" ||\n\t\t\tenvironment === \"split\"\n\t\t) {\n\t\t\tconst alignedAt = [\"alignedat\", \"alignat\", \"alignat*\"].includes(environment);\n\t\t\tconst alignedBody = alignedAt ? body.replace(/^\\s*\\{[^}]*\\}/, \"\") : body;\n\t\t\treturn this.splitEnvironmentRows(alignedBody)\n\t\t\t\t.map((row) => {\n\t\t\t\t\tconst cells = row.split(\"&\");\n\t\t\t\t\tconst source = alignedAt\n\t\t\t\t\t\t? Array.from({ length: Math.ceil(cells.length / 2) }, (_, index) =>\n\t\t\t\t\t\t\t\tcells.slice(index * 2, index * 2 + 2).join(\"\"),\n\t\t\t\t\t\t\t).join(\" \")\n\t\t\t\t\t\t: cells.join(\"\");\n\t\t\t\t\treturn this.renderNested(source).trim();\n\t\t\t\t})\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(\"\\n\");\n\t\t}\n\n\t\tif (environment === \"cases\" || environment === \"cases*\") {\n\t\t\tconst rows = this.splitEnvironmentRows(body)\n\t\t\t\t.map((row) => row.split(\"&\").map((cell) => this.renderNested(cell, false).trim()))\n\t\t\t\t.filter((row) => row.some(Boolean));\n\t\t\treturn rows\n\t\t\t\t.map((row, index) => {\n\t\t\t\t\tconst value = (row[0] ?? \"\").replace(/,\\s*$/, \"\");\n\t\t\t\t\tconst condition = row[1] ?? \"\";\n\t\t\t\t\tconst delimiter = index === 0 ? \"⎧\" : index === rows.length - 1 ? \"⎩\" : \"⎨\";\n\t\t\t\t\tconst conditionPrefix = /^(?:if|when|for|otherwise)\\b/i.test(condition) ? \" \" : \" if \";\n\t\t\t\t\treturn `${delimiter} ${value}${condition ? `${conditionPrefix}${condition}` : \"\"}`;\n\t\t\t\t})\n\t\t\t\t.join(\"\\n\");\n\t\t}\n\n\t\tif (\n\t\t\t[\"array\", \"matrix\", \"smallmatrix\", \"pmatrix\", \"bmatrix\", \"Bmatrix\", \"vmatrix\", \"Vmatrix\"].includes(environment)\n\t\t) {\n\t\t\tconst matrixBody = environment === \"array\" ? body.replace(/^\\s*\\{[^}]*\\}/, \"\") : body;\n\t\t\treturn this.renderMatrix(environment, matrixBody);\n\t\t}\n\n\t\tthis.supported = false;\n\t\treturn body;\n\t}\n\n\tprivate renderMatrix(environment: string, body: string): string {\n\t\tconst matrix = this.splitEnvironmentRows(body)\n\t\t\t.map((row) => row.split(\"&\").map((cell) => this.renderNested(cell, false).trim()))\n\t\t\t.filter((row) => row.some(Boolean));\n\t\tconst columnCount = Math.max(0, ...matrix.map((row) => row.length));\n\t\tconst columnWidths = Array.from({ length: columnCount }, (_, column) =>\n\t\t\tMath.max(0, ...matrix.map((row) => visibleWidth(row[column] ?? \"\"))),\n\t\t);\n\t\tconst rows = matrix.map((row) =>\n\t\t\tArray.from({ length: columnCount }, (_, column) => {\n\t\t\t\tconst cell = row[column] ?? \"\";\n\t\t\t\treturn `${cell}${PROTECTED_SPACE.repeat(Math.max(0, (columnWidths[column] ?? 0) - visibleWidth(cell)))}`;\n\t\t\t}).join(\" │ \"),\n\t\t);\n\n\t\tlet lines: string[];\n\t\tif (environment === \"array\" || environment === \"matrix\" || environment === \"smallmatrix\") {\n\t\t\tlines = rows;\n\t\t} else {\n\t\t\tconst delimiters: Readonly<Record<string, readonly [string, string, string, string, string, string]>> = {\n\t\t\t\tpmatrix: [\"⎛\", \"⎞\", \"⎜\", \"⎟\", \"⎝\", \"⎠\"],\n\t\t\t\tbmatrix: [\"⎡\", \"⎤\", \"⎢\", \"⎥\", \"⎣\", \"⎦\"],\n\t\t\t\tBmatrix: [\"⎧\", \"⎫\", \"⎨\", \"⎬\", \"⎩\", \"⎭\"],\n\t\t\t\tvmatrix: [\"│\", \"│\", \"│\", \"│\", \"│\", \"│\"],\n\t\t\t\tVmatrix: [\"║\", \"║\", \"║\", \"║\", \"║\", \"║\"],\n\t\t\t};\n\t\t\tconst delimiter = delimiters[environment];\n\t\t\tif (!delimiter) {\n\t\t\t\tthis.supported = false;\n\t\t\t\treturn rows.join(\"\\n\");\n\t\t\t}\n\t\t\tlines = rows.map((row, index) => {\n\t\t\t\tconst left = index === 0 ? delimiter[0] : index === rows.length - 1 ? delimiter[4] : delimiter[2];\n\t\t\t\tconst right = index === 0 ? delimiter[1] : index === rows.length - 1 ? delimiter[5] : delimiter[3];\n\t\t\t\treturn `${left} ${row} ${right}`;\n\t\t\t});\n\t\t}\n\n\t\tif (lines.length <= 1) {\n\t\t\treturn lines[0] ?? \"\";\n\t\t}\n\t\tconst index = this.layoutNodes.push({ type: \"matrix\", lines, baseline: 0 }) - 1;\n\t\treturn `${LAYOUT_MARKER_START}${index}${LAYOUT_MARKER_END}`;\n\t}\n\n\tprivate renderNested(source: string, stackFractions = true): string {\n\t\tconst rendered = new LatexParser(source, this.layoutNodes, this.display && stackFractions).render();\n\t\tif (rendered === undefined) {\n\t\t\tthis.supported = false;\n\t\t\treturn source;\n\t\t}\n\t\treturn rendered;\n\t}\n}\n\nexport interface RenderLatexOptions {\n\t/** Stack fractions and operator limits vertically for display math (default: false). */\n\tdisplay?: boolean;\n}\n\n/**\n * Render a basic LaTeX math expression as terminal-friendly Unicode text.\n * Returns undefined when the expression contains unsupported or malformed syntax.\n */\nexport function renderLatex(source: string, options: RenderLatexOptions = {}): string | undefined {\n\tconst layoutNodes: LayoutNode[] = [];\n\tconst rendered = new LatexParser(source, layoutNodes, options.display === true).render();\n\tif (rendered === undefined) {\n\t\treturn undefined;\n\t}\n\tif (layoutNodes.length === 0) {\n\t\treturn rendered.replaceAll(PROTECTED_SPACE, \" \");\n\t}\n\tconst lines = renderLayout(rendered, layoutNodes).lines;\n\tconst indentation = Math.min(\n\t\t...lines.filter((line) => line.trim()).map((line) => line.length - line.trimStart().length),\n\t);\n\treturn lines\n\t\t.map((line) => line.slice(indentation).trimEnd())\n\t\t.join(\"\\n\")\n\t\t.trimEnd()\n\t\t.replaceAll(PROTECTED_SPACE, \" \");\n}\n","// @ts-nocheck — vendored Pi source; checked upstream under Pi's own tsconfig.\nimport { execSync } from \"node:child_process\";\nimport { homedir } from \"node:os\";\nimport { isAbsolute } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nexport type ImageProtocol = \"kitty\" | \"iterm2\" | null;\n\nexport interface TerminalCapabilities {\n\timages: ImageProtocol;\n\ttrueColor: boolean;\n\thyperlinks: boolean;\n}\n\nexport interface CellDimensions {\n\twidthPx: number;\n\theightPx: number;\n}\n\nexport interface ImageDimensions {\n\twidthPx: number;\n\theightPx: number;\n}\n\nexport interface ImageRenderOptions {\n\tmaxWidthCells?: number;\n\tmaxHeightCells?: number;\n\tpreserveAspectRatio?: boolean;\n\t/** Kitty image ID. If provided, reuses/replaces existing image with this ID. */\n\timageId?: number;\n\t/** Whether Kitty should apply its default cursor movement after placement. */\n\tmoveCursor?: boolean;\n}\n\nlet cachedCapabilities: TerminalCapabilities | null = null;\n\n// Default cell dimensions - updated by TUI when terminal responds to query\nlet cellDimensions: CellDimensions = { widthPx: 9, heightPx: 18 };\n\nexport function getCellDimensions(): CellDimensions {\n\treturn cellDimensions;\n}\n\nexport function setCellDimensions(dims: CellDimensions): void {\n\tcellDimensions = dims;\n}\n\n/**\n * Checks whether the attached tmux client forwards OSC 8 hyperlinks to the\n * outer terminal. tmux only re-emits them when its `client_termfeatures` lists\n * `hyperlinks`, and strips them otherwise. On any error fallbacks `false`.\n */\nfunction probeTmuxHyperlinks(): boolean {\n\ttry {\n\t\tconst termfeatures = execSync(\"tmux display-message -p '#{client_termfeatures}'\", {\n\t\t\tencoding: \"utf8\",\n\t\t\ttimeout: 250,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"ignore\"],\n\t\t});\n\t\treturn termfeatures\n\t\t\t.split(\",\")\n\t\t\t.map((feature) => feature.trim())\n\t\t\t.includes(\"hyperlinks\");\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function detectCapabilities(tmuxForwardsHyperlink: () => boolean = probeTmuxHyperlinks): TerminalCapabilities {\n\tconst termProgram = process.env.TERM_PROGRAM?.toLowerCase() || \"\";\n\tconst terminalEmulator = process.env.TERMINAL_EMULATOR?.toLowerCase() || \"\";\n\tconst term = process.env.TERM?.toLowerCase() || \"\";\n\tconst colorTerm = process.env.COLORTERM?.toLowerCase() || \"\";\n\tconst hasTrueColorHint = colorTerm === \"truecolor\" || colorTerm === \"24bit\";\n\tconst isWindowsConsole = process.platform === \"win32\";\n\n\t// Emit OSC 8 hyperlinks only when tmux confirms it forwards.\n\t// Image protocols are unreliable under tmux, so leave `images: null`.\n\tif (process.env.TMUX || term.startsWith(\"tmux\")) {\n\t\treturn { images: null, trueColor: hasTrueColorHint, hyperlinks: tmuxForwardsHyperlink() };\n\t}\n\n\t// screen does not forward OSC 8 hyperlinks, so keep them off there.\n\tif (term.startsWith(\"screen\")) {\n\t\treturn { images: null, trueColor: hasTrueColorHint, hyperlinks: false };\n\t}\n\n\tif (process.env.KITTY_WINDOW_ID || termProgram === \"kitty\") {\n\t\treturn { images: \"kitty\", trueColor: true, hyperlinks: true };\n\t}\n\n\tif (termProgram === \"ghostty\" || term.includes(\"ghostty\") || process.env.GHOSTTY_RESOURCES_DIR) {\n\t\treturn { images: \"kitty\", trueColor: true, hyperlinks: true };\n\t}\n\n\tif (process.env.WEZTERM_PANE || termProgram === \"wezterm\") {\n\t\treturn { images: \"kitty\", trueColor: true, hyperlinks: true };\n\t}\n\n\t// Warp supports the Kitty graphics protocol and OSC 8 hyperlinks.\n\tif (termProgram === \"warpterminal\" || process.env.WARP_SESSION_ID || process.env.WARP_TERMINAL_SESSION_UUID) {\n\t\treturn { images: \"kitty\", trueColor: true, hyperlinks: true };\n\t}\n\n\tif (process.env.ITERM_SESSION_ID || termProgram === \"iterm.app\") {\n\t\treturn { images: \"iterm2\", trueColor: true, hyperlinks: true };\n\t}\n\n\tif (process.env.WT_SESSION) {\n\t\treturn { images: null, trueColor: true, hyperlinks: true };\n\t}\n\n\tif (termProgram === \"vscode\") {\n\t\treturn { images: null, trueColor: true, hyperlinks: true };\n\t}\n\n\tif (termProgram === \"alacritty\") {\n\t\treturn { images: null, trueColor: true, hyperlinks: true };\n\t}\n\n\tif (terminalEmulator === \"jetbrains-jediterm\") {\n\t\treturn { images: null, trueColor: true, hyperlinks: false };\n\t}\n\n\t// Windows Terminal does not always set WT_SESSION, for example when it hosts\n\t// a cmd.exe launched directly from Win+R. Modern Windows consoles support\n\t// truecolor; keep hyperlinks off unless we positively detected support above.\n\tif (isWindowsConsole) {\n\t\treturn { images: null, trueColor: true, hyperlinks: false };\n\t}\n\n\t// Unknown terminal: be conservative. OSC 8 is rendered invisibly as \"just\n\t// text\" on terminals that swallow it, which means the URL disappears from\n\t// the rendered output. Default to the legacy `text (url)` behavior unless we\n\t// have positively identified a hyperlink-capable terminal above.\n\treturn { images: null, trueColor: hasTrueColorHint, hyperlinks: false };\n}\n\nexport function getCapabilities(): TerminalCapabilities {\n\tif (!cachedCapabilities) {\n\t\tcachedCapabilities = detectCapabilities();\n\t}\n\treturn cachedCapabilities;\n}\n\nexport function resetCapabilitiesCache(): void {\n\tcachedCapabilities = null;\n}\n\n/** Override the cached capabilities. Useful in tests to exercise both code paths. */\nexport function setCapabilities(caps: TerminalCapabilities): void {\n\tcachedCapabilities = caps;\n}\n\nconst KITTY_PREFIX = \"\\x1b_G\";\nconst ITERM2_PREFIX = \"\\x1b]1337;File=\";\n\nexport function isImageLine(line: string): boolean {\n\t// Fast path: sequence at line start (single-row images)\n\tif (line.startsWith(KITTY_PREFIX) || line.startsWith(ITERM2_PREFIX)) {\n\t\treturn true;\n\t}\n\t// Slow path: sequence elsewhere (multi-row images have cursor-up prefix)\n\treturn line.includes(KITTY_PREFIX) || line.includes(ITERM2_PREFIX);\n}\n\n/**\n * Generate a random image ID for Kitty graphics protocol.\n * Uses random IDs to avoid collisions between different module instances\n * (e.g., main app vs extensions).\n */\nexport function allocateImageId(): number {\n\t// Use random ID in range [1, 0xffffffff] to avoid collisions\n\treturn Math.floor(Math.random() * 0xfffffffe) + 1;\n}\n\nexport function encodeKitty(\n\tbase64Data: string,\n\toptions: {\n\t\tcolumns?: number;\n\t\trows?: number;\n\t\timageId?: number;\n\t\t/** Whether Kitty should apply its default cursor movement after placement. Default: true. */\n\t\tmoveCursor?: boolean;\n\t} = {},\n): string {\n\tconst CHUNK_SIZE = 4096;\n\n\tconst params: string[] = [\"a=T\", \"f=100\", \"q=2\"];\n\n\tif (options.moveCursor === false) params.push(\"C=1\");\n\tif (options.columns) params.push(`c=${options.columns}`);\n\tif (options.rows) params.push(`r=${options.rows}`);\n\tif (options.imageId) params.push(`i=${options.imageId}`);\n\n\tif (base64Data.length <= CHUNK_SIZE) {\n\t\treturn `\\x1b_G${params.join(\",\")};${base64Data}\\x1b\\\\`;\n\t}\n\n\tconst chunks: string[] = [];\n\tlet offset = 0;\n\tlet isFirst = true;\n\n\twhile (offset < base64Data.length) {\n\t\tconst chunk = base64Data.slice(offset, offset + CHUNK_SIZE);\n\t\tconst isLast = offset + CHUNK_SIZE >= base64Data.length;\n\n\t\tif (isFirst) {\n\t\t\tchunks.push(`\\x1b_G${params.join(\",\")},m=1;${chunk}\\x1b\\\\`);\n\t\t\tisFirst = false;\n\t\t} else if (isLast) {\n\t\t\tchunks.push(`\\x1b_Gm=0;${chunk}\\x1b\\\\`);\n\t\t} else {\n\t\t\tchunks.push(`\\x1b_Gm=1;${chunk}\\x1b\\\\`);\n\t\t}\n\n\t\toffset += CHUNK_SIZE;\n\t}\n\n\treturn chunks.join(\"\");\n}\n\n/**\n * Delete a Kitty graphics image by ID.\n * Uses uppercase 'I' to also free the image data.\n */\nexport function deleteKittyImage(imageId: number): string {\n\treturn `\\x1b_Ga=d,d=I,i=${imageId},q=2\\x1b\\\\`;\n}\n\n/**\n * Delete all visible Kitty graphics images.\n * Uses uppercase 'A' to also free the image data.\n */\nexport function deleteAllKittyImages(): string {\n\treturn \"\\x1b_Ga=d,d=A,q=2\\x1b\\\\\";\n}\n\n/** Delete all visible Kitty placements while retaining their uploaded image data. */\nexport function deleteAllKittyPlacements(): string {\n\treturn \"\\x1b_Ga=d,d=a,q=2\\x1b\\\\\";\n}\n\nexport function encodeITerm2(\n\tbase64Data: string,\n\toptions: {\n\t\twidth?: number | string;\n\t\theight?: number | string;\n\t\tname?: string;\n\t\tpreserveAspectRatio?: boolean;\n\t\tinline?: boolean;\n\t} = {},\n): string {\n\tconst params: string[] = [\n\t\t`inline=${options.inline !== false ? 1 : 0}`,\n\t\t`size=${Buffer.byteLength(base64Data, \"base64\")}`,\n\t];\n\n\tif (options.width !== undefined) params.push(`width=${options.width}`);\n\tif (options.height !== undefined) params.push(`height=${options.height}`);\n\tif (options.name) {\n\t\tconst nameBase64 = Buffer.from(options.name).toString(\"base64\");\n\t\tparams.push(`name=${nameBase64}`);\n\t}\n\tif (options.preserveAspectRatio === false) {\n\t\tparams.push(\"preserveAspectRatio=0\");\n\t}\n\n\treturn `\\x1b]1337;File=${params.join(\";\")}:${base64Data}\\x07`;\n}\n\nexport interface ImageCellSize {\n\tcolumns: number;\n\trows: number;\n}\n\nexport interface KittyImageMetadata extends ImageCellSize {\n\timageId: number;\n\twidthPx: number;\n\theightPx: number;\n}\n\ninterface RegisteredKittyImageMetadata extends KittyImageMetadata {\n\ttransmissionGeneration: number;\n}\n\nexport interface KittyImagePlacement {\n\timageId: number;\n\ttransmissionGeneration: number;\n\ttransmissionBytes: number;\n\testimatedDecodedBytes: number;\n\tsequence: string;\n\treplacementLine: string;\n}\n\nconst kittyImageMetadata = new Map<number, RegisteredKittyImageMetadata>();\nlet kittyTransmissionGeneration = 0;\n\nexport function registerKittyImageMetadata(metadata: KittyImageMetadata): void {\n\tkittyTransmissionGeneration += 1;\n\tkittyImageMetadata.delete(metadata.imageId);\n\tkittyImageMetadata.set(metadata.imageId, { ...metadata, transmissionGeneration: kittyTransmissionGeneration });\n\tif (kittyImageMetadata.size > 1000) {\n\t\tconst oldestImageId = kittyImageMetadata.keys().next().value;\n\t\tif (oldestImageId !== undefined) kittyImageMetadata.delete(oldestImageId);\n\t}\n}\n\nfunction getRegisteredKittyImageMetadata(line: string): RegisteredKittyImageMetadata | undefined {\n\tconst controls = /\\x1b_G([^;]*);/.exec(line)?.[1];\n\tif (!controls) return undefined;\n\tconst imageId = /(?:^|,)i=(\\d+)(?:,|$)/.exec(controls)?.[1];\n\treturn imageId === undefined ? undefined : kittyImageMetadata.get(Number.parseInt(imageId, 10));\n}\n\nexport function getKittyImageMetadata(line: string): KittyImageMetadata | undefined {\n\tconst metadata = getRegisteredKittyImageMetadata(line);\n\tif (!metadata) return undefined;\n\treturn {\n\t\timageId: metadata.imageId,\n\t\tcolumns: metadata.columns,\n\t\trows: metadata.rows,\n\t\twidthPx: metadata.widthPx,\n\t\theightPx: metadata.heightPx,\n\t};\n}\n\nconst KITTY_PLACEMENT_CONTROL_KEYS = new Set([\n\t\"i\",\n\t\"p\",\n\t\"x\",\n\t\"y\",\n\t\"w\",\n\t\"h\",\n\t\"X\",\n\t\"Y\",\n\t\"c\",\n\t\"r\",\n\t\"C\",\n\t\"U\",\n\t\"z\",\n\t\"P\",\n\t\"Q\",\n\t\"H\",\n\t\"V\",\n]);\n\n/** Build a placement-only command for an image line emitted by {@link renderImage}. */\nexport function getKittyImagePlacement(line: string): KittyImagePlacement | undefined {\n\tconst match = /\\x1b_G([^;]*);/.exec(line);\n\tconst metadata = getRegisteredKittyImageMetadata(line);\n\tif (!match || !metadata) return undefined;\n\n\tlet commandStart = match.index;\n\tlet commandControls = match[1];\n\tlet transmissionEnd: number;\n\twhile (true) {\n\t\tconst terminator = line.indexOf(\"\\x1b\\\\\", commandStart + KITTY_PREFIX.length);\n\t\tif (terminator === -1) return undefined;\n\t\ttransmissionEnd = terminator + 2;\n\t\tif (!/(?:^|,)m=1(?:,|$)/.test(commandControls)) break;\n\t\tcommandStart = transmissionEnd;\n\t\tif (!line.startsWith(KITTY_PREFIX, commandStart)) return undefined;\n\t\tconst controlsEnd = line.indexOf(\";\", commandStart + KITTY_PREFIX.length);\n\t\tif (controlsEnd === -1) return undefined;\n\t\tcommandControls = line.slice(commandStart + KITTY_PREFIX.length, controlsEnd);\n\t}\n\n\tconst controls = match[1]\n\t\t.split(\",\")\n\t\t.filter((control) => KITTY_PLACEMENT_CONTROL_KEYS.has(control.split(\"=\", 1)[0] ?? \"\"));\n\tconst sequence = `\\x1b_Ga=p,q=2,${controls.join(\",\")}\\x1b\\\\`;\n\treturn {\n\t\timageId: metadata.imageId,\n\t\ttransmissionGeneration: metadata.transmissionGeneration,\n\t\ttransmissionBytes: transmissionEnd - match.index,\n\t\testimatedDecodedBytes: metadata.widthPx * metadata.heightPx * 4,\n\t\tsequence,\n\t\treplacementLine: `${line.slice(0, match.index)}${sequence}${line.slice(transmissionEnd)}`,\n\t};\n}\n\nexport function cropKittyImageLine(line: string, hiddenRows: number, visibleRows: number): string {\n\tconst metadata = getKittyImageMetadata(line);\n\tconst match = /\\x1b_G([^;]*);/.exec(line);\n\tif (!metadata || !match || hiddenRows < 0 || hiddenRows >= metadata.rows || visibleRows <= 0) return line;\n\tconst croppedRows = Math.min(visibleRows, metadata.rows - hiddenRows);\n\tif (hiddenRows === 0 && croppedRows === metadata.rows) return line;\n\tconst sourceY = Math.floor((metadata.heightPx * hiddenRows) / metadata.rows);\n\tconst sourceEnd = Math.ceil((metadata.heightPx * (hiddenRows + croppedRows)) / metadata.rows);\n\tconst sourceHeight = Math.max(1, Math.min(metadata.heightPx, sourceEnd) - sourceY);\n\tconst controls = match[1].split(\",\").filter((control) => !/^[yhr]=/.test(control));\n\tcontrols.push(`y=${sourceY}`, `h=${sourceHeight}`, `r=${croppedRows}`);\n\treturn `${line.slice(0, match.index)}\\x1b_G${controls.join(\",\")};${line.slice(match.index + match[0].length)}`;\n}\n\nexport function calculateImageCellSize(\n\timageDimensions: ImageDimensions,\n\tmaxWidthCells: number,\n\tmaxHeightCells?: number,\n\tcellDimensions: CellDimensions = { widthPx: 9, heightPx: 18 },\n): ImageCellSize {\n\tconst maxWidth = Math.max(1, Math.floor(maxWidthCells));\n\tconst maxHeight = maxHeightCells === undefined ? undefined : Math.max(1, Math.floor(maxHeightCells));\n\tconst imageWidth = Math.max(1, imageDimensions.widthPx);\n\tconst imageHeight = Math.max(1, imageDimensions.heightPx);\n\n\tconst widthScale = (maxWidth * cellDimensions.widthPx) / imageWidth;\n\tconst heightScale = maxHeight === undefined ? widthScale : (maxHeight * cellDimensions.heightPx) / imageHeight;\n\tconst scale = Math.min(widthScale, heightScale);\n\n\tconst scaledWidthPx = imageWidth * scale;\n\tconst scaledHeightPx = imageHeight * scale;\n\tconst columns = Math.ceil(scaledWidthPx / cellDimensions.widthPx);\n\tconst rows = Math.ceil(scaledHeightPx / cellDimensions.heightPx);\n\n\treturn {\n\t\tcolumns: Math.max(1, Math.min(maxWidth, columns)),\n\t\trows: Math.max(1, maxHeight === undefined ? rows : Math.min(maxHeight, rows)),\n\t};\n}\n\nexport function calculateImageRows(\n\timageDimensions: ImageDimensions,\n\ttargetWidthCells: number,\n\tcellDimensions: CellDimensions = { widthPx: 9, heightPx: 18 },\n): number {\n\treturn calculateImageCellSize(imageDimensions, targetWidthCells, undefined, cellDimensions).rows;\n}\n\nexport function getPngDimensions(base64Data: string): ImageDimensions | null {\n\ttry {\n\t\tconst buffer = Buffer.from(base64Data, \"base64\");\n\n\t\tif (buffer.length < 24) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (buffer[0] !== 0x89 || buffer[1] !== 0x50 || buffer[2] !== 0x4e || buffer[3] !== 0x47) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst width = buffer.readUInt32BE(16);\n\t\tconst height = buffer.readUInt32BE(20);\n\n\t\treturn { widthPx: width, heightPx: height };\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport function getJpegDimensions(base64Data: string): ImageDimensions | null {\n\ttry {\n\t\tconst buffer = Buffer.from(base64Data, \"base64\");\n\n\t\tif (buffer.length < 2) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (buffer[0] !== 0xff || buffer[1] !== 0xd8) {\n\t\t\treturn null;\n\t\t}\n\n\t\tlet offset = 2;\n\t\twhile (offset < buffer.length - 9) {\n\t\t\tif (buffer[offset] !== 0xff) {\n\t\t\t\toffset++;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst marker = buffer[offset + 1];\n\n\t\t\tif (marker >= 0xc0 && marker <= 0xc2) {\n\t\t\t\tconst height = buffer.readUInt16BE(offset + 5);\n\t\t\t\tconst width = buffer.readUInt16BE(offset + 7);\n\t\t\t\treturn { widthPx: width, heightPx: height };\n\t\t\t}\n\n\t\t\tif (offset + 3 >= buffer.length) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst length = buffer.readUInt16BE(offset + 2);\n\t\t\tif (length < 2) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\toffset += 2 + length;\n\t\t}\n\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport function getGifDimensions(base64Data: string): ImageDimensions | null {\n\ttry {\n\t\tconst buffer = Buffer.from(base64Data, \"base64\");\n\n\t\tif (buffer.length < 10) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst sig = buffer.slice(0, 6).toString(\"ascii\");\n\t\tif (sig !== \"GIF87a\" && sig !== \"GIF89a\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst width = buffer.readUInt16LE(6);\n\t\tconst height = buffer.readUInt16LE(8);\n\n\t\treturn { widthPx: width, heightPx: height };\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport function getWebpDimensions(base64Data: string): ImageDimensions | null {\n\ttry {\n\t\tconst buffer = Buffer.from(base64Data, \"base64\");\n\n\t\tif (buffer.length < 30) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst riff = buffer.slice(0, 4).toString(\"ascii\");\n\t\tconst webp = buffer.slice(8, 12).toString(\"ascii\");\n\t\tif (riff !== \"RIFF\" || webp !== \"WEBP\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst chunk = buffer.slice(12, 16).toString(\"ascii\");\n\t\tif (chunk === \"VP8 \") {\n\t\t\tif (buffer.length < 30) return null;\n\t\t\tconst width = buffer.readUInt16LE(26) & 0x3fff;\n\t\t\tconst height = buffer.readUInt16LE(28) & 0x3fff;\n\t\t\treturn { widthPx: width, heightPx: height };\n\t\t} else if (chunk === \"VP8L\") {\n\t\t\tif (buffer.length < 25) return null;\n\t\t\tconst bits = buffer.readUInt32LE(21);\n\t\t\tconst width = (bits & 0x3fff) + 1;\n\t\t\tconst height = ((bits >> 14) & 0x3fff) + 1;\n\t\t\treturn { widthPx: width, heightPx: height };\n\t\t} else if (chunk === \"VP8X\") {\n\t\t\tif (buffer.length < 30) return null;\n\t\t\tconst width = (buffer[24] | (buffer[25] << 8) | (buffer[26] << 16)) + 1;\n\t\t\tconst height = (buffer[27] | (buffer[28] << 8) | (buffer[29] << 16)) + 1;\n\t\t\treturn { widthPx: width, heightPx: height };\n\t\t}\n\n\t\treturn null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport function getImageDimensions(base64Data: string, mimeType: string): ImageDimensions | null {\n\tif (mimeType === \"image/png\") {\n\t\treturn getPngDimensions(base64Data);\n\t}\n\tif (mimeType === \"image/jpeg\") {\n\t\treturn getJpegDimensions(base64Data);\n\t}\n\tif (mimeType === \"image/gif\") {\n\t\treturn getGifDimensions(base64Data);\n\t}\n\tif (mimeType === \"image/webp\") {\n\t\treturn getWebpDimensions(base64Data);\n\t}\n\treturn null;\n}\n\nexport function renderImage(\n\tbase64Data: string,\n\timageDimensions: ImageDimensions,\n\toptions: ImageRenderOptions = {},\n): { sequence: string; columns: number; rows: number; imageId?: number } | null {\n\tconst caps = getCapabilities();\n\n\tif (!caps.images) {\n\t\treturn null;\n\t}\n\n\tconst maxWidth = options.maxWidthCells ?? 80;\n\tconst size = calculateImageCellSize(imageDimensions, maxWidth, options.maxHeightCells, getCellDimensions());\n\n\tif (caps.images === \"kitty\") {\n\t\tif (options.imageId !== undefined) {\n\t\t\tregisterKittyImageMetadata({\n\t\t\t\timageId: options.imageId,\n\t\t\t\tcolumns: size.columns,\n\t\t\t\trows: size.rows,\n\t\t\t\twidthPx: imageDimensions.widthPx,\n\t\t\t\theightPx: imageDimensions.heightPx,\n\t\t\t});\n\t\t}\n\t\tconst sequence = encodeKitty(base64Data, {\n\t\t\tcolumns: size.columns,\n\t\t\trows: size.rows,\n\t\t\timageId: options.imageId,\n\t\t\tmoveCursor: options.moveCursor,\n\t\t});\n\t\treturn { sequence, columns: size.columns, rows: size.rows, imageId: options.imageId };\n\t}\n\n\tif (caps.images === \"iterm2\") {\n\t\tconst sequence = encodeITerm2(base64Data, {\n\t\t\twidth: size.columns,\n\t\t\theight: \"auto\",\n\t\t\tpreserveAspectRatio: options.preserveAspectRatio ?? true,\n\t\t});\n\t\treturn { sequence, columns: size.columns, rows: size.rows };\n\t}\n\n\treturn null;\n}\n\n/**\n * Wrap text in an OSC 8 hyperlink sequence.\n * The text is rendered as a clickable hyperlink in terminals that support OSC 8\n * (Ghostty, Kitty, WezTerm, iTerm2, VSCode, and others).\n * In terminals that do not support OSC 8, the escape sequences are ignored\n * and only the plain text is displayed.\n *\n * @param text - The visible text to display\n * @param url - The URL to link to\n */\nexport function hyperlink(text: string, url: string): string {\n\treturn `\\x1b]8;;${url}\\x1b\\\\${text}\\x1b]8;;\\x1b\\\\`;\n}\n\n/** Shorten home-prefixed absolute paths to ~/... for compact display. */\nfunction shortenImagePath(filename: string): string {\n\tconst home = homedir();\n\tif (home && (filename === home || filename.startsWith(`${home}/`) || filename.startsWith(`${home}\\\\`))) {\n\t\treturn `~${filename.slice(home.length)}`;\n\t}\n\treturn filename;\n}\n\n/**\n * Text fallback when the terminal cannot render inline images.\n * Absolute paths are shown shortened (~/...) and, when OSC 8 hyperlinks are\n * available, linked to file:// so the full path remains openable.\n */\nexport function imageFallback(mimeType: string, dimensions?: ImageDimensions, filename?: string): string {\n\tconst parts: string[] = [];\n\tif (filename) {\n\t\tconst display = shortenImagePath(filename);\n\t\tif (getCapabilities().hyperlinks && isAbsolute(filename)) {\n\t\t\tparts.push(hyperlink(display, pathToFileURL(filename).href));\n\t\t} else {\n\t\t\tparts.push(display);\n\t\t}\n\t}\n\tparts.push(`[${mimeType}]`);\n\tif (dimensions) parts.push(`${dimensions.widthPx}x${dimensions.heightPx}`);\n\treturn `[Image: ${parts.join(\" \")}]`;\n}\n","// @ts-nocheck — vendored Pi source; checked upstream under Pi's own tsconfig.\nimport { spawn } from \"child_process\";\nimport { readdirSync, statSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { basename, dirname, join } from \"path\";\nimport { fuzzyFilter } from \"./pi-tui-fuzzy.ts\";\n\nconst PATH_DELIMITERS = new Set([\" \", \"\\t\", '\"', \"'\", \"=\"]);\n\nfunction toDisplayPath(value: string): string {\n\treturn value.replace(/\\\\/g, \"/\");\n}\n\nfunction escapeRegex(value: string): string {\n\treturn value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nfunction buildFdPathQuery(query: string): string {\n\tconst normalized = toDisplayPath(query);\n\tif (!normalized.includes(\"/\")) {\n\t\treturn normalized;\n\t}\n\n\tconst hasTrailingSeparator = normalized.endsWith(\"/\");\n\tconst trimmed = normalized.replace(/^\\/+|\\/+$/g, \"\");\n\tif (!trimmed) {\n\t\treturn normalized;\n\t}\n\n\tconst separatorPattern = \"[\\\\\\\\/]\";\n\tconst segments = trimmed\n\t\t.split(\"/\")\n\t\t.filter(Boolean)\n\t\t.map((segment) => escapeRegex(segment));\n\tif (segments.length === 0) {\n\t\treturn normalized;\n\t}\n\n\tlet pattern = segments.join(separatorPattern);\n\tif (hasTrailingSeparator) {\n\t\tpattern += separatorPattern;\n\t}\n\treturn pattern;\n}\n\nfunction findLastDelimiter(text: string): number {\n\tfor (let i = text.length - 1; i >= 0; i -= 1) {\n\t\tif (PATH_DELIMITERS.has(text[i] ?? \"\")) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\nfunction findUnclosedQuoteStart(text: string): number | null {\n\tlet inQuotes = false;\n\tlet quoteStart = -1;\n\n\tfor (let i = 0; i < text.length; i += 1) {\n\t\tif (text[i] === '\"') {\n\t\t\tinQuotes = !inQuotes;\n\t\t\tif (inQuotes) {\n\t\t\t\tquoteStart = i;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn inQuotes ? quoteStart : null;\n}\n\nfunction isTokenStart(text: string, index: number): boolean {\n\treturn index === 0 || PATH_DELIMITERS.has(text[index - 1] ?? \"\");\n}\n\nfunction extractQuotedPrefix(text: string): string | null {\n\tconst quoteStart = findUnclosedQuoteStart(text);\n\tif (quoteStart === null) {\n\t\treturn null;\n\t}\n\n\tif (quoteStart > 0 && text[quoteStart - 1] === \"@\") {\n\t\tif (!isTokenStart(text, quoteStart - 1)) {\n\t\t\treturn null;\n\t\t}\n\t\treturn text.slice(quoteStart - 1);\n\t}\n\n\tif (!isTokenStart(text, quoteStart)) {\n\t\treturn null;\n\t}\n\n\treturn text.slice(quoteStart);\n}\n\nfunction parsePathPrefix(prefix: string): { rawPrefix: string; isAtPrefix: boolean; isQuotedPrefix: boolean } {\n\tif (prefix.startsWith('@\"')) {\n\t\treturn { rawPrefix: prefix.slice(2), isAtPrefix: true, isQuotedPrefix: true };\n\t}\n\tif (prefix.startsWith('\"')) {\n\t\treturn { rawPrefix: prefix.slice(1), isAtPrefix: false, isQuotedPrefix: true };\n\t}\n\tif (prefix.startsWith(\"@\")) {\n\t\treturn { rawPrefix: prefix.slice(1), isAtPrefix: true, isQuotedPrefix: false };\n\t}\n\treturn { rawPrefix: prefix, isAtPrefix: false, isQuotedPrefix: false };\n}\n\nfunction buildCompletionValue(\n\tpath: string,\n\toptions: { isDirectory: boolean; isAtPrefix: boolean; isQuotedPrefix: boolean },\n): string {\n\tconst needsQuotes = options.isQuotedPrefix || path.includes(\" \");\n\tconst prefix = options.isAtPrefix ? \"@\" : \"\";\n\n\tif (!needsQuotes) {\n\t\treturn `${prefix}${path}`;\n\t}\n\n\tconst openQuote = `${prefix}\"`;\n\tconst closeQuote = '\"';\n\treturn `${openQuote}${path}${closeQuote}`;\n}\n\n// Use fd to walk directory tree (fast, respects .gitignore)\nasync function walkDirectoryWithFd(\n\tbaseDir: string,\n\tfdPath: string,\n\tquery: string,\n\tmaxResults: number,\n\tsignal: AbortSignal,\n): Promise<Array<{ path: string; isDirectory: boolean }>> {\n\tconst args = [\n\t\t\"--base-directory\",\n\t\tbaseDir,\n\t\t\"--max-results\",\n\t\tString(maxResults),\n\t\t\"--type\",\n\t\t\"f\",\n\t\t\"--type\",\n\t\t\"d\",\n\t\t\"--follow\",\n\t\t\"--hidden\",\n\t\t\"--exclude\",\n\t\t\".git\",\n\t\t\"--exclude\",\n\t\t\".git/*\",\n\t\t\"--exclude\",\n\t\t\".git/**\",\n\t];\n\n\tif (toDisplayPath(query).includes(\"/\")) {\n\t\targs.push(\"--full-path\");\n\t}\n\n\tif (query) {\n\t\targs.push(buildFdPathQuery(query));\n\t}\n\n\treturn await new Promise((resolve) => {\n\t\tif (signal.aborted) {\n\t\t\tresolve([]);\n\t\t\treturn;\n\t\t}\n\n\t\tconst child = spawn(fdPath, args, {\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t});\n\t\tlet stdout = \"\";\n\t\tlet resolved = false;\n\n\t\tconst finish = (results: Array<{ path: string; isDirectory: boolean }>) => {\n\t\t\tif (resolved) return;\n\t\t\tresolved = true;\n\t\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve(results);\n\t\t};\n\n\t\tconst onAbort = () => {\n\t\t\tif (child.exitCode === null) {\n\t\t\t\tchild.kill(\"SIGKILL\");\n\t\t\t}\n\t\t};\n\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\tchild.stdout.setEncoding(\"utf-8\");\n\t\tchild.stdout.on(\"data\", (chunk: string) => {\n\t\t\tstdout += chunk;\n\t\t});\n\t\tchild.on(\"error\", () => {\n\t\t\tfinish([]);\n\t\t});\n\t\tchild.on(\"close\", (code) => {\n\t\t\tif (signal.aborted || code !== 0 || !stdout) {\n\t\t\t\tfinish([]);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst lines = stdout.trim().split(\"\\n\").filter(Boolean);\n\t\t\tconst results: Array<{ path: string; isDirectory: boolean }> = [];\n\n\t\t\tfor (const line of lines) {\n\t\t\t\tconst displayLine = toDisplayPath(line);\n\t\t\t\tconst hasTrailingSeparator = displayLine.endsWith(\"/\");\n\t\t\t\tconst normalizedPath = hasTrailingSeparator ? displayLine.slice(0, -1) : displayLine;\n\t\t\t\tif (normalizedPath === \".git\" || normalizedPath.startsWith(\".git/\") || normalizedPath.includes(\"/.git/\")) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tresults.push({\n\t\t\t\t\tpath: displayLine,\n\t\t\t\t\tisDirectory: hasTrailingSeparator,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfinish(results);\n\t\t});\n\t});\n}\n\nexport interface AutocompleteItem {\n\tvalue: string;\n\tlabel: string;\n\tdescription?: string;\n}\n\ntype Awaitable<T> = T | Promise<T>;\n\nexport interface SlashCommand {\n\tname: string;\n\tdescription?: string;\n\targumentHint?: string;\n\t// Function to get argument completions for this command\n\t// Returns null if no argument completion is available\n\tgetArgumentCompletions?(argumentPrefix: string): Awaitable<AutocompleteItem[] | null>;\n}\n\nexport interface AutocompleteSuggestions {\n\titems: AutocompleteItem[];\n\tprefix: string; // What we're matching against (e.g., \"/\" or \"src/\")\n}\n\nexport interface AutocompleteProvider {\n\t/** Characters that should naturally trigger this provider at token boundaries. */\n\ttriggerCharacters?: string[];\n\n\t// Get autocomplete suggestions for current text/cursor position\n\t// Returns null if no suggestions available\n\tgetSuggestions(\n\t\tlines: string[],\n\t\tcursorLine: number,\n\t\tcursorCol: number,\n\t\toptions: { signal: AbortSignal; force?: boolean },\n\t): Promise<AutocompleteSuggestions | null>;\n\n\t// Apply the selected item\n\t// Returns the new text and cursor position\n\tapplyCompletion(\n\t\tlines: string[],\n\t\tcursorLine: number,\n\t\tcursorCol: number,\n\t\titem: AutocompleteItem,\n\t\tprefix: string,\n\t): {\n\t\tlines: string[];\n\t\tcursorLine: number;\n\t\tcursorCol: number;\n\t};\n\n\t// Check if file completion should trigger for explicit Tab completion\n\tshouldTriggerFileCompletion?(lines: string[], cursorLine: number, cursorCol: number): boolean;\n}\n\n// Combined provider that handles both slash commands and file paths\nexport class CombinedAutocompleteProvider implements AutocompleteProvider {\n\tprivate commands: (SlashCommand | AutocompleteItem)[];\n\tprivate basePath: string;\n\tprivate fdPath: string | null;\n\n\tconstructor(commands: (SlashCommand | AutocompleteItem)[] = [], basePath: string, fdPath: string | null = null) {\n\t\tthis.commands = commands;\n\t\tthis.basePath = basePath;\n\t\tthis.fdPath = fdPath;\n\t}\n\n\tasync getSuggestions(\n\t\tlines: string[],\n\t\tcursorLine: number,\n\t\tcursorCol: number,\n\t\toptions: { signal: AbortSignal; force?: boolean },\n\t): Promise<AutocompleteSuggestions | null> {\n\t\tconst currentLine = lines[cursorLine] || \"\";\n\t\tconst textBeforeCursor = currentLine.slice(0, cursorCol);\n\n\t\tconst atPrefix = this.extractAtPrefix(textBeforeCursor);\n\t\tif (atPrefix) {\n\t\t\tconst { rawPrefix, isQuotedPrefix } = parsePathPrefix(atPrefix);\n\t\t\tconst suggestions = await this.getFuzzyFileSuggestions(rawPrefix, {\n\t\t\t\tisQuotedPrefix,\n\t\t\t\tsignal: options.signal,\n\t\t\t});\n\t\t\tif (suggestions.length === 0) return null;\n\n\t\t\treturn {\n\t\t\t\titems: suggestions,\n\t\t\t\tprefix: atPrefix,\n\t\t\t};\n\t\t}\n\n\t\tif (!options.force && textBeforeCursor.startsWith(\"/\")) {\n\t\t\tconst spaceIndex = textBeforeCursor.indexOf(\" \");\n\n\t\t\tif (spaceIndex === -1) {\n\t\t\t\tconst prefix = textBeforeCursor.slice(1);\n\t\t\t\tconst commandItems = this.commands.map((cmd) => {\n\t\t\t\t\tconst name = \"name\" in cmd ? cmd.name : cmd.value;\n\t\t\t\t\tconst hint = \"argumentHint\" in cmd && cmd.argumentHint ? cmd.argumentHint : undefined;\n\t\t\t\t\tconst desc = cmd.description ?? \"\";\n\t\t\t\t\tconst fullDesc = hint ? (desc ? `${hint} — ${desc}` : hint) : desc;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tlabel: name,\n\t\t\t\t\t\tdescription: fullDesc || undefined,\n\t\t\t\t\t};\n\t\t\t\t});\n\n\t\t\t\tconst filtered = fuzzyFilter(commandItems, prefix, (item) => item.name).map((item) => ({\n\t\t\t\t\tvalue: item.name,\n\t\t\t\t\tlabel: item.label,\n\t\t\t\t\t...(item.description && { description: item.description }),\n\t\t\t\t}));\n\n\t\t\t\tif (filtered.length === 0) return null;\n\n\t\t\t\treturn {\n\t\t\t\t\titems: filtered,\n\t\t\t\t\tprefix: textBeforeCursor,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst commandName = textBeforeCursor.slice(1, spaceIndex);\n\t\t\tconst argumentText = textBeforeCursor.slice(spaceIndex + 1);\n\n\t\t\tconst command = this.commands.find((cmd) => {\n\t\t\t\tconst name = \"name\" in cmd ? cmd.name : cmd.value;\n\t\t\t\treturn name === commandName;\n\t\t\t});\n\t\t\tif (!command || !(\"getArgumentCompletions\" in command) || !command.getArgumentCompletions) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst argumentSuggestions = await command.getArgumentCompletions(argumentText);\n\t\t\tif (!Array.isArray(argumentSuggestions) || argumentSuggestions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\titems: argumentSuggestions,\n\t\t\t\tprefix: argumentText,\n\t\t\t};\n\t\t}\n\n\t\tconst pathMatch = this.extractPathPrefix(textBeforeCursor, options.force ?? false);\n\t\tif (pathMatch === null) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst suggestions = this.getFileSuggestions(pathMatch);\n\t\tif (suggestions.length === 0) return null;\n\n\t\treturn {\n\t\t\titems: suggestions,\n\t\t\tprefix: pathMatch,\n\t\t};\n\t}\n\n\tapplyCompletion(\n\t\tlines: string[],\n\t\tcursorLine: number,\n\t\tcursorCol: number,\n\t\titem: AutocompleteItem,\n\t\tprefix: string,\n\t): { lines: string[]; cursorLine: number; cursorCol: number } {\n\t\tconst currentLine = lines[cursorLine] || \"\";\n\t\tconst beforePrefix = currentLine.slice(0, cursorCol - prefix.length);\n\t\tconst afterCursor = currentLine.slice(cursorCol);\n\t\tconst isQuotedPrefix = prefix.startsWith('\"') || prefix.startsWith('@\"');\n\t\tconst hasLeadingQuoteAfterCursor = afterCursor.startsWith('\"');\n\t\tconst hasTrailingQuoteInItem = item.value.endsWith('\"');\n\t\tconst adjustedAfterCursor =\n\t\t\tisQuotedPrefix && hasTrailingQuoteInItem && hasLeadingQuoteAfterCursor ? afterCursor.slice(1) : afterCursor;\n\n\t\t// Check if we're completing a slash command (prefix starts with \"/\" but NOT a file path)\n\t\t// Slash commands are at the start of the line and don't contain path separators after the first /\n\t\tconst isSlashCommand = prefix.startsWith(\"/\") && beforePrefix.trim() === \"\" && !prefix.slice(1).includes(\"/\");\n\t\tif (isSlashCommand) {\n\t\t\t// This is a command name completion\n\t\t\tconst newLine = `${beforePrefix}/${item.value} ${adjustedAfterCursor}`;\n\t\t\tconst newLines = [...lines];\n\t\t\tnewLines[cursorLine] = newLine;\n\n\t\t\treturn {\n\t\t\t\tlines: newLines,\n\t\t\t\tcursorLine,\n\t\t\t\tcursorCol: beforePrefix.length + item.value.length + 2, // +2 for \"/\" and space\n\t\t\t};\n\t\t}\n\n\t\t// Check if we're completing a file attachment (prefix starts with \"@\")\n\t\tif (prefix.startsWith(\"@\")) {\n\t\t\t// This is a file attachment completion\n\t\t\t// Don't add space after directories so user can continue autocompleting\n\t\t\tconst isDirectory = item.label.endsWith(\"/\");\n\t\t\tconst suffix = isDirectory ? \"\" : \" \";\n\t\t\tconst newLine = `${beforePrefix + item.value}${suffix}${adjustedAfterCursor}`;\n\t\t\tconst newLines = [...lines];\n\t\t\tnewLines[cursorLine] = newLine;\n\n\t\t\tconst hasTrailingQuote = item.value.endsWith('\"');\n\t\t\tconst cursorOffset = isDirectory && hasTrailingQuote ? item.value.length - 1 : item.value.length;\n\n\t\t\treturn {\n\t\t\t\tlines: newLines,\n\t\t\t\tcursorLine,\n\t\t\t\tcursorCol: beforePrefix.length + cursorOffset + suffix.length,\n\t\t\t};\n\t\t}\n\n\t\t// Check if we're in a slash command context (beforePrefix contains \"/command \")\n\t\tconst textBeforeCursor = currentLine.slice(0, cursorCol);\n\t\tif (textBeforeCursor.includes(\"/\") && textBeforeCursor.includes(\" \")) {\n\t\t\t// This is likely a command argument completion\n\t\t\tconst newLine = beforePrefix + item.value + adjustedAfterCursor;\n\t\t\tconst newLines = [...lines];\n\t\t\tnewLines[cursorLine] = newLine;\n\n\t\t\tconst isDirectory = item.label.endsWith(\"/\");\n\t\t\tconst hasTrailingQuote = item.value.endsWith('\"');\n\t\t\tconst cursorOffset = isDirectory && hasTrailingQuote ? item.value.length - 1 : item.value.length;\n\n\t\t\treturn {\n\t\t\t\tlines: newLines,\n\t\t\t\tcursorLine,\n\t\t\t\tcursorCol: beforePrefix.length + cursorOffset,\n\t\t\t};\n\t\t}\n\n\t\t// For file paths, complete the path\n\t\tconst newLine = beforePrefix + item.value + adjustedAfterCursor;\n\t\tconst newLines = [...lines];\n\t\tnewLines[cursorLine] = newLine;\n\n\t\tconst isDirectory = item.label.endsWith(\"/\");\n\t\tconst hasTrailingQuote = item.value.endsWith('\"');\n\t\tconst cursorOffset = isDirectory && hasTrailingQuote ? item.value.length - 1 : item.value.length;\n\n\t\treturn {\n\t\t\tlines: newLines,\n\t\t\tcursorLine,\n\t\t\tcursorCol: beforePrefix.length + cursorOffset,\n\t\t};\n\t}\n\n\t// Extract @ prefix for fuzzy file suggestions\n\tprivate extractAtPrefix(text: string): string | null {\n\t\tconst quotedPrefix = extractQuotedPrefix(text);\n\t\tif (quotedPrefix?.startsWith('@\"')) {\n\t\t\treturn quotedPrefix;\n\t\t}\n\n\t\tconst lastDelimiterIndex = findLastDelimiter(text);\n\t\tconst tokenStart = lastDelimiterIndex === -1 ? 0 : lastDelimiterIndex + 1;\n\n\t\tif (text[tokenStart] === \"@\") {\n\t\t\treturn text.slice(tokenStart);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t// Extract a path-like prefix from the text before cursor\n\tprivate extractPathPrefix(text: string, forceExtract: boolean = false): string | null {\n\t\tconst quotedPrefix = extractQuotedPrefix(text);\n\t\tif (quotedPrefix) {\n\t\t\treturn quotedPrefix;\n\t\t}\n\n\t\tconst lastDelimiterIndex = findLastDelimiter(text);\n\t\tconst pathPrefix = lastDelimiterIndex === -1 ? text : text.slice(lastDelimiterIndex + 1);\n\n\t\t// For forced extraction (Tab key), always return something\n\t\tif (forceExtract) {\n\t\t\treturn pathPrefix;\n\t\t}\n\n\t\t// For natural triggers, return if it looks like a path, ends with /, starts with ~/, .\n\t\t// Only return empty string if the text looks like it's starting a path context\n\t\tif (pathPrefix.includes(\"/\") || pathPrefix.startsWith(\".\") || pathPrefix.startsWith(\"~/\")) {\n\t\t\treturn pathPrefix;\n\t\t}\n\n\t\t// Return empty string only after a space (not for completely empty text)\n\t\t// Empty text should not trigger file suggestions - that's for forced Tab completion\n\t\tif (pathPrefix === \"\" && text.endsWith(\" \")) {\n\t\t\treturn pathPrefix;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t// Expand home directory (~/) to actual home path\n\tprivate expandHomePath(path: string): string {\n\t\tif (path.startsWith(\"~/\")) {\n\t\t\tconst expandedPath = join(homedir(), path.slice(2));\n\t\t\t// Preserve trailing slash if original path had one\n\t\t\treturn path.endsWith(\"/\") && !expandedPath.endsWith(\"/\") ? `${expandedPath}/` : expandedPath;\n\t\t} else if (path === \"~\") {\n\t\t\treturn homedir();\n\t\t}\n\t\treturn path;\n\t}\n\n\tprivate resolveScopedFuzzyQuery(rawQuery: string): { baseDir: string; query: string; displayBase: string } | null {\n\t\tconst normalizedQuery = toDisplayPath(rawQuery);\n\t\tconst slashIndex = normalizedQuery.lastIndexOf(\"/\");\n\t\tif (slashIndex === -1) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst displayBase = normalizedQuery.slice(0, slashIndex + 1);\n\t\tconst query = normalizedQuery.slice(slashIndex + 1);\n\n\t\tlet baseDir: string;\n\t\tif (displayBase.startsWith(\"~/\")) {\n\t\t\tbaseDir = this.expandHomePath(displayBase);\n\t\t} else if (displayBase.startsWith(\"/\")) {\n\t\t\tbaseDir = displayBase;\n\t\t} else {\n\t\t\tbaseDir = join(this.basePath, displayBase);\n\t\t}\n\n\t\ttry {\n\t\t\tif (!statSync(baseDir).isDirectory()) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn { baseDir, query, displayBase };\n\t}\n\n\tprivate scopedPathForDisplay(displayBase: string, relativePath: string): string {\n\t\tconst normalizedRelativePath = toDisplayPath(relativePath);\n\t\tif (displayBase === \"/\") {\n\t\t\treturn `/${normalizedRelativePath}`;\n\t\t}\n\t\treturn `${toDisplayPath(displayBase)}${normalizedRelativePath}`;\n\t}\n\n\t// Get file/directory suggestions for a given path prefix\n\tprivate getFileSuggestions(prefix: string): AutocompleteItem[] {\n\t\ttry {\n\t\t\tlet searchDir: string;\n\t\t\tlet searchPrefix: string;\n\t\t\tconst { rawPrefix, isAtPrefix, isQuotedPrefix } = parsePathPrefix(prefix);\n\t\t\tlet expandedPrefix = rawPrefix;\n\n\t\t\t// Handle home directory expansion\n\t\t\tif (expandedPrefix.startsWith(\"~\")) {\n\t\t\t\texpandedPrefix = this.expandHomePath(expandedPrefix);\n\t\t\t}\n\n\t\t\tconst isRootPrefix =\n\t\t\t\trawPrefix === \"\" ||\n\t\t\t\trawPrefix === \"./\" ||\n\t\t\t\trawPrefix === \"../\" ||\n\t\t\t\trawPrefix === \"~\" ||\n\t\t\t\trawPrefix === \"~/\" ||\n\t\t\t\trawPrefix === \"/\" ||\n\t\t\t\t(isAtPrefix && rawPrefix === \"\");\n\n\t\t\tif (isRootPrefix) {\n\t\t\t\t// Complete from specified position\n\t\t\t\tif (rawPrefix.startsWith(\"~\") || expandedPrefix.startsWith(\"/\")) {\n\t\t\t\t\tsearchDir = expandedPrefix;\n\t\t\t\t} else {\n\t\t\t\t\tsearchDir = join(this.basePath, expandedPrefix);\n\t\t\t\t}\n\t\t\t\tsearchPrefix = \"\";\n\t\t\t} else if (rawPrefix.endsWith(\"/\")) {\n\t\t\t\t// If prefix ends with /, show contents of that directory\n\t\t\t\tif (rawPrefix.startsWith(\"~\") || expandedPrefix.startsWith(\"/\")) {\n\t\t\t\t\tsearchDir = expandedPrefix;\n\t\t\t\t} else {\n\t\t\t\t\tsearchDir = join(this.basePath, expandedPrefix);\n\t\t\t\t}\n\t\t\t\tsearchPrefix = \"\";\n\t\t\t} else {\n\t\t\t\t// Split into directory and file prefix\n\t\t\t\tconst dir = dirname(expandedPrefix);\n\t\t\t\tconst file = basename(expandedPrefix);\n\t\t\t\tif (rawPrefix.startsWith(\"~\") || expandedPrefix.startsWith(\"/\")) {\n\t\t\t\t\tsearchDir = dir;\n\t\t\t\t} else {\n\t\t\t\t\tsearchDir = join(this.basePath, dir);\n\t\t\t\t}\n\t\t\t\tsearchPrefix = file;\n\t\t\t}\n\n\t\t\tconst entries = readdirSync(searchDir, { withFileTypes: true });\n\t\t\tconst suggestions: AutocompleteItem[] = [];\n\n\t\t\tfor (const entry of entries) {\n\t\t\t\tif (!entry.name.toLowerCase().startsWith(searchPrefix.toLowerCase())) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Check if entry is a directory (or a symlink pointing to a directory)\n\t\t\t\tlet isDirectory = entry.isDirectory();\n\t\t\t\tif (!isDirectory && entry.isSymbolicLink()) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst fullPath = join(searchDir, entry.name);\n\t\t\t\t\t\tisDirectory = statSync(fullPath).isDirectory();\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// Broken symlink or permission error - treat as file\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet relativePath: string;\n\t\t\t\tconst name = entry.name;\n\t\t\t\tconst displayPrefix = rawPrefix;\n\n\t\t\t\tif (displayPrefix.endsWith(\"/\")) {\n\t\t\t\t\t// If prefix ends with /, append entry to the prefix\n\t\t\t\t\trelativePath = displayPrefix + name;\n\t\t\t\t} else if (displayPrefix.includes(\"/\") || displayPrefix.includes(\"\\\\\")) {\n\t\t\t\t\t// Preserve ~/ format for home directory paths\n\t\t\t\t\tif (displayPrefix.startsWith(\"~/\")) {\n\t\t\t\t\t\tconst homeRelativeDir = displayPrefix.slice(2); // Remove ~/\n\t\t\t\t\t\tconst dir = dirname(homeRelativeDir);\n\t\t\t\t\t\trelativePath = `~/${dir === \".\" ? name : join(dir, name)}`;\n\t\t\t\t\t} else if (displayPrefix.startsWith(\"/\")) {\n\t\t\t\t\t\t// Absolute path - construct properly\n\t\t\t\t\t\tconst dir = dirname(displayPrefix);\n\t\t\t\t\t\tif (dir === \"/\") {\n\t\t\t\t\t\t\trelativePath = `/${name}`;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trelativePath = `${dir}/${name}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\trelativePath = join(dirname(displayPrefix), name);\n\t\t\t\t\t\t// path.join normalizes away ./ prefix, preserve it\n\t\t\t\t\t\tif (displayPrefix.startsWith(\"./\") && !relativePath.startsWith(\"./\")) {\n\t\t\t\t\t\t\trelativePath = `./${relativePath}`;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// For standalone entries, preserve ~/ if original prefix was ~/\n\t\t\t\t\tif (displayPrefix.startsWith(\"~\")) {\n\t\t\t\t\t\trelativePath = `~/${name}`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\trelativePath = name;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\trelativePath = toDisplayPath(relativePath);\n\t\t\t\tconst pathValue = isDirectory ? `${relativePath}/` : relativePath;\n\t\t\t\tconst value = buildCompletionValue(pathValue, {\n\t\t\t\t\tisDirectory,\n\t\t\t\t\tisAtPrefix,\n\t\t\t\t\tisQuotedPrefix,\n\t\t\t\t});\n\n\t\t\t\tsuggestions.push({\n\t\t\t\t\tvalue,\n\t\t\t\t\tlabel: name + (isDirectory ? \"/\" : \"\"),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Sort directories first, then alphabetically\n\t\t\tsuggestions.sort((a, b) => {\n\t\t\t\tconst aIsDir = a.value.endsWith(\"/\");\n\t\t\t\tconst bIsDir = b.value.endsWith(\"/\");\n\t\t\t\tif (aIsDir && !bIsDir) return -1;\n\t\t\t\tif (!aIsDir && bIsDir) return 1;\n\t\t\t\treturn a.label.localeCompare(b.label);\n\t\t\t});\n\n\t\t\treturn suggestions;\n\t\t} catch (_e) {\n\t\t\t// Directory doesn't exist or not accessible\n\t\t\treturn [];\n\t\t}\n\t}\n\n\t// Score an entry against the query (higher = better match)\n\t// isDirectory adds bonus to prioritize folders\n\tprivate scoreEntry(filePath: string, query: string, isDirectory: boolean): number {\n\t\tconst fileName = basename(filePath);\n\t\tconst lowerFileName = fileName.toLowerCase();\n\t\tconst lowerQuery = query.toLowerCase();\n\n\t\tlet score = 0;\n\n\t\t// Exact filename match (highest)\n\t\tif (lowerFileName === lowerQuery) score = 100;\n\t\t// Filename starts with query\n\t\telse if (lowerFileName.startsWith(lowerQuery)) score = 80;\n\t\t// Substring match in filename\n\t\telse if (lowerFileName.includes(lowerQuery)) score = 50;\n\t\t// Substring match in full path\n\t\telse if (filePath.toLowerCase().includes(lowerQuery)) score = 30;\n\n\t\t// Directories get a bonus to appear first\n\t\tif (isDirectory && score > 0) score += 10;\n\n\t\treturn score;\n\t}\n\n\t// Fuzzy file search using fd (fast, respects .gitignore)\n\tprivate async getFuzzyFileSuggestions(\n\t\tquery: string,\n\t\toptions: { isQuotedPrefix: boolean; signal: AbortSignal },\n\t): Promise<AutocompleteItem[]> {\n\t\tif (!this.fdPath || options.signal.aborted) {\n\t\t\treturn [];\n\t\t}\n\n\t\ttry {\n\t\t\tconst scopedQuery = this.resolveScopedFuzzyQuery(query);\n\t\t\tconst fdBaseDir = scopedQuery?.baseDir ?? this.basePath;\n\t\t\tconst fdQuery = scopedQuery?.query ?? query;\n\t\t\tconst entries = await walkDirectoryWithFd(fdBaseDir, this.fdPath, fdQuery, 100, options.signal);\n\t\t\tif (options.signal.aborted) {\n\t\t\t\treturn [];\n\t\t\t}\n\n\t\t\tconst scoredEntries = entries\n\t\t\t\t.map((entry) => ({\n\t\t\t\t\t...entry,\n\t\t\t\t\tscore: fdQuery ? this.scoreEntry(entry.path, fdQuery, entry.isDirectory) : 1,\n\t\t\t\t}))\n\t\t\t\t.filter((entry) => entry.score > 0);\n\n\t\t\tscoredEntries.sort((a, b) => b.score - a.score);\n\t\t\tconst topEntries = scoredEntries.slice(0, 20);\n\n\t\t\tconst suggestions: AutocompleteItem[] = [];\n\t\t\tfor (const { path: entryPath, isDirectory } of topEntries) {\n\t\t\t\tconst pathWithoutSlash = isDirectory ? entryPath.slice(0, -1) : entryPath;\n\t\t\t\tconst displayPath = scopedQuery\n\t\t\t\t\t? this.scopedPathForDisplay(scopedQuery.displayBase, pathWithoutSlash)\n\t\t\t\t\t: pathWithoutSlash;\n\t\t\t\tconst entryName = basename(pathWithoutSlash);\n\t\t\t\tconst completionPath = isDirectory ? `${displayPath}/` : displayPath;\n\t\t\t\tconst value = buildCompletionValue(completionPath, {\n\t\t\t\t\tisDirectory,\n\t\t\t\t\tisAtPrefix: true,\n\t\t\t\t\tisQuotedPrefix: options.isQuotedPrefix,\n\t\t\t\t});\n\n\t\t\t\tsuggestions.push({\n\t\t\t\t\tvalue,\n\t\t\t\t\tlabel: entryName + (isDirectory ? \"/\" : \"\"),\n\t\t\t\t\tdescription: displayPath,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn suggestions;\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\n\t// Check if we should trigger file completion (called on Tab key)\n\tshouldTriggerFileCompletion(lines: string[], cursorLine: number, cursorCol: number): boolean {\n\t\tconst currentLine = lines[cursorLine] || \"\";\n\t\tconst textBeforeCursor = currentLine.slice(0, cursorCol);\n\n\t\t// Don't trigger if we're typing a slash command at the start of the line\n\t\tif (textBeforeCursor.trim().startsWith(\"/\") && !textBeforeCursor.trim().includes(\" \")) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n}\n","// Headless @earendil-works/pi-tui compatibility surface.\n//\n// Pure text/measurement/key logic is vendored byte-identical from Pi (see\n// ./vendor/PI-LICENSE), so extensions observe identical widths, wrapping,\n// key names, fuzzy ranking, and keybinding tables. Interactive component\n// classes are headless: identical constructor/method signatures, plain-text\n// render output, no terminal I/O. Pi itself defines headless behavior for\n// json/print modes (noOpUIContext) and rpc `ui.custom` (undefined); these\n// classes exist so extensions can load and construct UI trees without a TTY.\n\nexport {\n applyBackgroundToLine,\n cjkBreakRegex,\n extractAnsiCode,\n getGraphemeCellRange,\n getGraphemeSegmenter,\n getOsc8LinkAtColumn,\n getWordSegmenter,\n isPunctuationChar,\n isWhitespaceChar,\n normalizeTerminalOutput,\n PUNCTUATION_REGEX,\n sliceByColumn,\n sliceWithWidth,\n stripTerminalSequences,\n truncateToWidth,\n visibleWidth,\n wrapTextWithAnsi,\n} from './vendor/pi-tui-utils.js'\nexport { fuzzyFilter, fuzzyMatch, type FuzzyMatch } from './vendor/pi-tui-fuzzy.js'\nexport {\n decodeKittyPrintable,\n isKeyRelease,\n isKeyRepeat,\n isKittyProtocolActive,\n Key,\n type KeyEventType,\n type KeyId,\n matchesKey,\n parseKey,\n setKittyProtocolActive,\n} from './vendor/pi-tui-keys.js'\nexport {\n parseOsc11BackgroundColor,\n parseTerminalColorSchemeReport,\n type RgbColor,\n type TerminalColorScheme,\n} from './vendor/pi-tui-terminal-colors.js'\nexport {\n getKeybindings,\n type Keybinding,\n type KeybindingConflict,\n type KeybindingDefinition,\n type KeybindingDefinitions,\n type Keybindings,\n type KeybindingsConfig,\n KeybindingsManager,\n setKeybindings,\n TUI_KEYBINDINGS,\n} from './vendor/pi-tui-keybindings.js'\nexport { renderLatex, type RenderLatexOptions } from './vendor/pi-tui-latex.js'\nexport {\n allocateImageId,\n calculateImageRows,\n type CellDimensions,\n deleteAllKittyImages,\n deleteKittyImage,\n detectCapabilities,\n encodeITerm2,\n encodeKitty,\n getCapabilities,\n getCellDimensions,\n getGifDimensions,\n getImageDimensions,\n getJpegDimensions,\n getPngDimensions,\n getWebpDimensions,\n hyperlink,\n type ImageDimensions,\n imageFallback,\n type ImageProtocol,\n resetCapabilitiesCache,\n setCapabilities,\n setCellDimensions,\n type TerminalCapabilities,\n} from './vendor/pi-tui-terminal-image.js'\nexport {\n type AutocompleteItem,\n type AutocompleteProvider,\n type AutocompleteSuggestions,\n CombinedAutocompleteProvider,\n type SlashCommand,\n} from './vendor/pi-tui-autocomplete.js'\nexport { Marked, type Token, type Tokens } from 'marked'\n\nimport { truncateToWidth, visibleWidth, wrapTextWithAnsi } from './vendor/pi-tui-utils.js'\nimport type { AutocompleteProvider } from './vendor/pi-tui-autocomplete.js'\n\n// Pi's cursor-position marker: an APC sequence stripped by visibleWidth.\nexport const CURSOR_MARKER = '\\x1b_pi:c\\x07'\n\nexport interface Component {\n render(width: number): string[]\n invalidate(): void\n handleInput?(data: string): void\n wantsKeyRelease?: boolean\n}\n\nexport interface Focusable {\n focused: boolean\n}\n\nexport function isFocusable(value: unknown): value is Focusable {\n return typeof value === 'object' && value !== null && 'focused' in value\n}\n\nfunction blankLines(count: number): string[] {\n return Array.from({ length: Math.max(0, count) }, () => '')\n}\n\nexport class Container implements Component {\n children: Component[] = []\n addChild(child: Component): void {\n this.children.push(child)\n }\n removeChild(child: Component): void {\n this.children = this.children.filter(candidate => candidate !== child)\n }\n clear(): void {\n this.children = []\n }\n invalidate(): void {\n for (const child of this.children) child.invalidate()\n }\n render(width: number): string[] {\n return this.children.flatMap(child => child.render(width))\n }\n}\n\nexport class Text implements Component {\n private customBgFn: ((text: string) => string) | undefined\n constructor(\n public text: string = '',\n public paddingX: number = 1,\n public paddingY: number = 1,\n customBgFn?: (text: string) => string,\n ) {\n this.customBgFn = customBgFn\n }\n setText(text: string): void {\n this.text = text\n }\n setCustomBgFn(customBgFn?: (text: string) => string): void {\n this.customBgFn = customBgFn\n }\n invalidate(): void {}\n render(width: number): string[] {\n const pad = ' '.repeat(Math.max(0, this.paddingX))\n const inner = Math.max(1, width - this.paddingX * 2)\n const lines = this.text.split('\\n').flatMap(line => wrapTextWithAnsi(line, inner))\n const rendered = lines.map(line => {\n const value = `${pad}${line}${pad}`\n return this.customBgFn === undefined ? value : this.customBgFn(value)\n })\n return [...blankLines(this.paddingY), ...rendered, ...blankLines(this.paddingY)]\n }\n}\n\nexport class TruncatedText implements Component {\n constructor(\n public text: string,\n public paddingX: number = 0,\n public paddingY: number = 0,\n ) {}\n invalidate(): void {}\n render(width: number): string[] {\n const pad = ' '.repeat(Math.max(0, this.paddingX))\n const inner = Math.max(1, width - this.paddingX * 2)\n const lines = this.text.split('\\n').map(line => `${pad}${truncateToWidth(line, inner)}${pad}`)\n return [...blankLines(this.paddingY), ...lines, ...blankLines(this.paddingY)]\n }\n}\n\nexport class Spacer implements Component {\n constructor(private lines: number = 1) {}\n setLines(lines: number): void {\n this.lines = lines\n }\n invalidate(): void {}\n render(_width: number): string[] {\n return blankLines(this.lines)\n }\n}\n\nexport class Box implements Component {\n private children: Component[] = []\n private bgFn: ((text: string) => string) | undefined\n constructor(\n public paddingX: number = 1,\n public paddingY: number = 1,\n bgFn?: (text: string) => string,\n ) {\n this.bgFn = bgFn\n }\n addChild(component: Component): void {\n this.children.push(component)\n }\n removeChild(component: Component): void {\n this.children = this.children.filter(candidate => candidate !== component)\n }\n clear(): void {\n this.children = []\n }\n setBgFn(bgFn?: (text: string) => string): void {\n this.bgFn = bgFn\n }\n invalidate(): void {\n for (const child of this.children) child.invalidate()\n }\n render(width: number): string[] {\n const pad = ' '.repeat(Math.max(0, this.paddingX))\n const inner = Math.max(1, width - this.paddingX * 2)\n const lines = this.children.flatMap(child => child.render(inner))\n const rendered = [...blankLines(this.paddingY), ...lines.map(line => `${pad}${line}${pad}`), ...blankLines(this.paddingY)]\n return this.bgFn === undefined ? rendered : rendered.map(line => this.bgFn!(line))\n }\n}\n\nexport interface MarkdownTheme {\n [key: string]: unknown\n}\nexport interface MarkdownOptions {\n [key: string]: unknown\n}\nexport type DefaultTextStyle = (text: string) => string\n\nexport class Markdown implements Component {\n constructor(\n public text: string = '',\n public paddingX: number = 1,\n public paddingY: number = 1,\n private theme?: MarkdownTheme,\n private options?: MarkdownOptions,\n ) {}\n setText(text: string): void {\n this.text = text\n }\n invalidate(): void {}\n render(width: number): string[] {\n const pad = ' '.repeat(Math.max(0, this.paddingX))\n const inner = Math.max(1, width - this.paddingX * 2)\n const lines = this.text.split('\\n').flatMap(line => wrapTextWithAnsi(line, inner))\n return [...blankLines(this.paddingY), ...lines.map(line => `${pad}${line}${pad}`), ...blankLines(this.paddingY)]\n }\n}\n\nexport interface SelectItem {\n value: string\n label: string\n description?: string\n}\nexport interface SelectListTheme {\n selectedPrefix?: unknown\n selectedText?: unknown\n description?: unknown\n scrollInfo?: unknown\n noMatch?: unknown\n [key: string]: unknown\n}\nexport interface SelectListLayoutOptions {\n minPrimaryColumnWidth?: number\n maxPrimaryColumnWidth?: number\n truncatePrimary?: unknown\n}\nexport interface SelectListTruncatePrimaryContext {\n [key: string]: unknown\n}\n\nexport class SelectList implements Component {\n onSelect?: (item: SelectItem) => void\n onCancel?: () => void\n onSelectionChange?: (item: SelectItem) => void\n private filtered: SelectItem[]\n private selectedIndex = 0\n constructor(\n private items: SelectItem[],\n private maxVisible: number,\n private theme: SelectListTheme,\n private layout: SelectListLayoutOptions = {},\n ) {\n this.filtered = [...items]\n }\n setFilter(filter: string): void {\n const query = filter.toLowerCase()\n this.filtered = this.items.filter(item =>\n item.label.toLowerCase().includes(query) || item.value.toLowerCase().includes(query))\n this.selectedIndex = 0\n }\n setSelectedIndex(index: number): void {\n this.selectedIndex = Math.max(0, Math.min(index, this.filtered.length - 1))\n }\n getSelectedItem(): SelectItem | null {\n return this.filtered[this.selectedIndex] ?? null\n }\n invalidate(): void {}\n handleInput(_keyData: string): void {}\n render(width: number): string[] {\n return this.filtered.slice(0, this.maxVisible)\n .map((item, index) => truncateToWidth(`${index === this.selectedIndex ? '→ ' : ' '}${item.label}`, Math.max(1, width)))\n }\n}\n\nexport interface SettingItem {\n id: string\n label: string\n description?: string\n currentValue: string\n values?: string[]\n submenu?: (currentValue: string, done: (selectedValue?: string) => void) => Component\n}\nexport interface SettingsListTheme {\n label?: unknown\n value?: unknown\n description?: unknown\n cursor?: unknown\n hint?: unknown\n [key: string]: unknown\n}\nexport interface SettingsListOptions {\n enableSearch?: boolean\n}\n\nexport class SettingsList implements Component {\n constructor(\n private items: SettingItem[],\n private maxVisible: number,\n private theme: SettingsListTheme,\n private onChange: (id: string, newValue: string) => void,\n private onCancel: () => void,\n private options: SettingsListOptions = {},\n ) {}\n updateValue(id: string, newValue: string): void {\n const item = this.items.find(candidate => candidate.id === id)\n if (item !== undefined) item.currentValue = newValue\n }\n invalidate(): void {}\n handleInput(_data: string): void {}\n render(width: number): string[] {\n return this.items.slice(0, this.maxVisible)\n .map(item => truncateToWidth(`${item.label}: ${item.currentValue}`, Math.max(1, width)))\n }\n}\n\nexport class Input implements Component, Focusable {\n focused = false\n onSubmit?: (value: string) => void\n onEscape?: () => void\n private value = ''\n getValue(): string {\n return this.value\n }\n setValue(value: string): void {\n this.value = value\n }\n handleInput(data: string): void {\n if (data === '\\r' || data === '\\n') {\n this.onSubmit?.(this.value)\n return\n }\n if (data === '\\x1b') {\n this.onEscape?.()\n return\n }\n if (data >= ' ') this.value += data\n }\n invalidate(): void {}\n render(width: number): string[] {\n return [truncateToWidth(this.value, Math.max(1, width))]\n }\n}\n\nexport interface EditorTheme {\n borderColor?: (s: string) => string\n selectList?: SelectListTheme\n [key: string]: unknown\n}\nexport interface EditorOptions {\n paddingX?: number\n autocompleteMaxVisible?: number\n}\n\nexport interface EditorComponent {\n getText(): string\n setText(text: string): void\n handleInput(data: string): void\n onSubmit?: (text: string) => void\n onChange?: (text: string) => void\n addToHistory?(text: string): void\n insertTextAtCursor?(text: string): void\n getExpandedText?(): string\n setAutocompleteProvider?(provider: AutocompleteProvider): void\n}\n\nexport class Editor implements Component, Focusable, EditorComponent {\n focused = false\n borderColor: (str: string) => string = str => str\n onSubmit?: (text: string) => void\n onChange?: (text: string) => void\n disableSubmit = false\n private text = ''\n private history: string[] = []\n private autocompleteProvider?: AutocompleteProvider\n constructor(\n private tui?: unknown,\n private theme: EditorTheme = {},\n private options: EditorOptions = {},\n ) {}\n getText(): string {\n return this.text\n }\n setText(text: string): void {\n this.text = text\n this.onChange?.(text)\n }\n getExpandedText(): string {\n return this.text\n }\n insertTextAtCursor(text: string): void {\n this.setText(this.text + text)\n }\n addToHistory(text: string): void {\n this.history.push(text)\n }\n setAutocompleteProvider(provider: AutocompleteProvider): void {\n this.autocompleteProvider = provider\n }\n getPaddingX(): number {\n return this.options.paddingX ?? 0\n }\n setPaddingX(padding: number): void {\n this.options.paddingX = padding\n }\n getAutocompleteMaxVisible(): number {\n return this.options.autocompleteMaxVisible ?? 5\n }\n setAutocompleteMaxVisible(maxVisible: number): void {\n this.options.autocompleteMaxVisible = maxVisible\n }\n handleInput(data: string): void {\n if (data === '\\r' || data === '\\n') {\n if (!this.disableSubmit) this.onSubmit?.(this.text)\n return\n }\n if (data >= ' ') this.setText(this.text + data)\n }\n invalidate(): void {}\n render(width: number): string[] {\n return this.text.split('\\n').flatMap(line => wrapTextWithAnsi(line, Math.max(1, width)))\n }\n}\n\nexport interface StackEntryOptions {\n [key: string]: unknown\n}\nexport type StackChild = Component | { component: Component; options?: StackEntryOptions }\nexport interface StackEntry {\n component: Component\n options?: StackEntryOptions\n}\nexport interface StackOptions {\n [key: string]: unknown\n}\n\nclass Stack extends Container {\n constructor(children: StackChild[] = [], protected options: StackOptions = {}) {\n super()\n for (const child of children) {\n this.addChild('component' in child ? child.component : child)\n }\n }\n}\n\nexport class VStack extends Stack {}\n\nexport class HStack extends Stack {\n override render(width: number): string[] {\n const columns = this.children.map(child => child.render(width))\n const height = Math.max(0, ...columns.map(column => column.length))\n const lines: string[] = []\n for (let row = 0; row < height; row += 1) {\n lines.push(columns.map(column => column[row] ?? '').join(' '))\n }\n return lines\n }\n}\n\nexport interface LoaderIndicatorOptions {\n frames?: string[]\n intervalMs?: number\n}\n\nexport class Loader extends Text {\n constructor(message = '', indicator?: LoaderIndicatorOptions) {\n super(message, 0, 0)\n void indicator\n }\n start(): void {}\n stop(): void {}\n setMessage(message: string): void {\n this.setText(message)\n }\n setIndicator(_indicator?: LoaderIndicatorOptions): void {}\n}\n\nexport class CancellableLoader extends Loader {\n onCancel?: () => void\n handleInput(data: string): void {\n if (data === '\\x1b' || data === '\\x03') this.onCancel?.()\n }\n dispose(): void {}\n}\n\nexport interface ImageOptions {\n [key: string]: unknown\n}\nexport interface ImageTheme {\n [key: string]: unknown\n}\n\nexport class Image implements Component {\n constructor(\n private base64Data: string = '',\n private mimeType: string = 'image/png',\n private options: ImageOptions = {},\n ) {}\n getImageId(): number | undefined {\n return undefined\n }\n invalidate(): void {}\n render(width: number): string[] {\n return [truncateToWidth(`[image ${this.mimeType}]`, Math.max(1, width))]\n }\n}\n\nexport interface ScrollViewScrollbar {\n [key: string]: unknown\n}\nexport interface ScrollViewOptions {\n [key: string]: unknown\n}\nexport interface ScrollViewScrollToOptions {\n [key: string]: unknown\n}\n\nexport class ScrollView extends Container {\n private scrollTop = 0\n constructor(component: Component, private options: ScrollViewOptions = {}) {\n super()\n this.addChild(component)\n }\n setScrollbar(_scrollbar: ScrollViewScrollbar): void {}\n getContentWidth(width: number): number {\n return Math.max(1, width - 1)\n }\n setScrollbarActive(_active: boolean): void {}\n scrollTo(scrollTop: number, _options: ScrollViewScrollToOptions = {}): void {\n this.scrollTop = Math.max(0, scrollTop)\n }\n scrollBy(lines: number): number {\n this.scrollTop = Math.max(0, this.scrollTop + lines)\n return this.scrollTop\n }\n scrollToStart(): void {\n this.scrollTop = 0\n }\n scrollToEnd(): void {}\n updateLayout(_contentHeight: number, _viewportHeight: number, _requestRender: () => void): void {}\n}\n\nexport interface OverlayMargin {\n top?: number\n right?: number\n bottom?: number\n left?: number\n}\nexport type SizeValue = number | `${number}%`\nexport interface OverlayAnchor {\n [key: string]: unknown\n}\nexport interface OverlayOptions {\n width?: SizeValue\n maxHeight?: SizeValue\n anchor?: OverlayAnchor\n margin?: OverlayMargin\n [key: string]: unknown\n}\nexport interface OverlayUnfocusOptions {\n [key: string]: unknown\n}\nexport interface OverlayHandle {\n close(): void\n [key: string]: unknown\n}\nexport type TuiMode = 'regular' | 'fullscreen'\nexport interface TuiStopOptions {\n preserveScreen?: boolean\n}\nexport type TuiInputListenerResult = { consume?: boolean; data?: string } | undefined\nexport type TuiInputListener = (data: string) => TuiInputListenerResult\n\nexport interface TUI extends Component {\n addChild(child: Component): void\n removeChild(child: Component): void\n clear(): void\n setFocus(component: Component | null): void\n showOverlay(component: Component, options?: OverlayOptions): OverlayHandle\n hideOverlay(): void\n hasOverlay(): boolean\n requestRender(): void\n [key: string]: unknown\n}\nexport interface ViewportTUI extends TUI {\n [key: string]: unknown\n}\nexport function isViewportTUI(value: unknown): value is ViewportTUI {\n return false\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,WAAW,OAAe,MAA0B;CACnE,MAAM,aAAa,MAAM,YAAY;CACrC,MAAM,YAAY,KAAK,YAAY;CAEnC,MAAM,cAAc,oBAAwC;EAC3D,IAAI,gBAAgB,WAAW,GAC9B,OAAO;GAAE,SAAS;GAAM,OAAO;EAAE;EAGlC,IAAI,gBAAgB,SAAS,UAAU,QACtC,OAAO;GAAE,SAAS;GAAO,OAAO;EAAE;EAGnC,IAAI,aAAa;EACjB,IAAI,QAAQ;EACZ,IAAI,iBAAiB;EACrB,IAAI,qBAAqB;EAEzB,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,UAAU,aAAa,gBAAgB,QAAQ,K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ACJ,IAAI;CACJ,QAAQ;CACR,QAAQ;CACR,MAAM;CACN,OAAO;CACP,OAAO;CACP,MAAM;CACN,OAAO;CACP,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,OAAO;CACP,OAAO;AACR;AAEA,MAAM,kCAAkB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAED,MAAM,kCAAkB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAED,MAAM,wCAAwB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAED,MAAM,oCAAoB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAED,MAAM,kBAAoD;CACzD,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;AACN;AAEA,MAAM,aAA+C;CACpD,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACJ;AAEA,MAAM,eAAiD;CACtD,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACJ;AAEA,MAAM,aAA+C;CACpD,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACJ;AAEA,MAAM,mCAAmB,IAAI,IAAI;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AACD,MAAM,4CAA4B,IAAI,IAA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