{"version":3,"file":"top-bar.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/top-bar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,KAAK,EAAa,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAIlF,KAAK,SAAS,GACX;IACA,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACnB,GACD,SAAS,CAAC;AAEb,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,MAAM,SAAS,CAAC;IAC1B,gBAAgB,EAAE,MAAM,MAAM,CAAC;IAC/B,WAAW,EAAE,kBAAkB,CAAC;CAChC;AAkCD,qBAAa,MAAO,YAAW,SAAS;IAC3B,OAAO,CAAC,OAAO;IAA3B,YAAoB,OAAO,EAAE,aAAa,EAAI;IAE9C,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,gBAAgB;IAexB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAkC9B;IAED,UAAU,IAAI,IAAI,CAAG;CACrB","sourcesContent":["import type { Component } from \"@apholdings/jensen-tui\";\nimport { visibleWidth } from \"@apholdings/jensen-tui\";\nimport type { AppAction, KeybindingsManager } from \"../../../core/keybindings.js\";\nimport { type ThemeColor, theme } from \"../theme/theme.js\";\nimport { appKey } from \"./keybinding-hints.js\";\n\ntype ModelLike =\n\t| {\n\t\t\tprovider?: string;\n\t\t\tapiProvider?: string;\n\t\t\tid?: string;\n\t\t\tmodelId?: string;\n\t\t\tname?: string;\n\t\t\treasoning?: boolean;\n\t  }\n\t| undefined;\n\nexport interface TopBarOptions {\n\tgetModel: () => ModelLike;\n\tgetThinkingLevel: () => string;\n\tkeybindings: KeybindingsManager;\n}\n\nfunction shortenProvider(input: string): string {\n\treturn input\n\t\t.replace(/^anthropic$/i, \"claude\")\n\t\t.replace(/^openai$/i, \"openai\")\n\t\t.replace(/^google$/i, \"google\")\n\t\t.replace(/^zai$/i, \"z.ai\")\n\t\t.replace(/^openrouter$/i, \"orouter\");\n}\n\nfunction shortenModelName(input: string): string {\n\treturn input\n\t\t.replace(/^anthropic\\//, \"\")\n\t\t.replace(/^openai\\//, \"\")\n\t\t.replace(/^google\\//, \"\")\n\t\t.replace(/^zai\\//, \"\")\n\t\t.replace(/^openrouter\\//, \"\")\n\t\t.replace(/^claude-/, \"\")\n\t\t.replace(/^models\\//, \"\");\n}\n\nfunction capitalizeKey(key: string): string {\n\treturn key\n\t\t.split(\"/\")\n\t\t.map((k) =>\n\t\t\tk\n\t\t\t\t.split(\"+\")\n\t\t\t\t.map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n\t\t\t\t.join(\"+\"),\n\t\t)\n\t\t.join(\"/\");\n}\n\nexport class TopBar implements Component {\n\tconstructor(private options: TopBarOptions) {}\n\n\tprivate getAppKeyDisplay(action: AppAction): string {\n\t\treturn capitalizeKey(appKey(this.options.keybindings, action));\n\t}\n\n\tprivate getProviderModel(): { provider: string; model: string } {\n\t\tconst model = this.options.getModel();\n\t\tif (!model) {\n\t\t\treturn { provider: \"no-provider\", model: \"no-model\" };\n\t\t}\n\n\t\tconst provider = model.provider ?? model.apiProvider ?? \"unknown\";\n\t\tconst rawModel = model.id ?? model.modelId ?? model.name ?? \"unknown-model\";\n\n\t\treturn {\n\t\t\tprovider: shortenProvider(String(provider)),\n\t\t\tmodel: shortenModelName(String(rawModel)),\n\t\t};\n\t}\n\n\trender(width: number): string[] {\n\t\tconst model = this.options.getModel();\n\t\tconst parts: string[] = [];\n\n\t\tif (model?.reasoning) {\n\t\t\tconst level = this.options.getThinkingLevel();\n\t\t\tconst colorKey = `thinking${level.charAt(0).toUpperCase()}${level.slice(1)}` as ThemeColor;\n\n\t\t\tparts.push(\n\t\t\t\ttheme.fg(\"accent\", this.getAppKeyDisplay(\"cycleThinkingLevel\")) +\n\t\t\t\t\ttheme.fg(\"text\", \" Thinking: \") +\n\t\t\t\t\ttheme.fg(colorKey, level),\n\t\t\t);\n\t\t}\n\n\t\tparts.push(theme.fg(\"accent\", this.getAppKeyDisplay(\"selectModel\")) + theme.fg(\"text\", \" Model\"));\n\n\t\tconst leftString = ` ${parts.join(theme.fg(\"dim\", \" · \"))}`;\n\t\tconst pm = this.getProviderModel();\n\n\t\tconst rightCandidates = [\n\t\t\ttheme.fg(\"accent\", `${pm.provider}/`) + theme.fg(\"text\", `${pm.model} `),\n\t\t\ttheme.fg(\"text\", `${pm.model} `),\n\t\t\t\"\",\n\t\t];\n\n\t\tconst maxRightWidth = Math.max(0, width - visibleWidth(leftString));\n\t\tconst rightString = rightCandidates.find((candidate) => visibleWidth(candidate) <= maxRightWidth) ?? \"\";\n\n\t\tconst leftWidth = visibleWidth(leftString);\n\t\tconst rightWidth = visibleWidth(rightString);\n\t\tconst spaces = Math.max(0, width - leftWidth - rightWidth);\n\n\t\treturn [leftString + \" \".repeat(spaces) + rightString];\n\t}\n\n\tinvalidate(): void {}\n}\n"]}