{"version":3,"file":"session-chip.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/session-chip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAiC,MAAM,0BAA0B,CAAC;AAwBpG;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,sDAAsD;AACtD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAenG","sourcesContent":["import { type EditorTopBorderLabel, truncateToWidth, visibleWidth } from \"@kolisachint/hoocode-tui\";\nimport { sessionColorToken, theme } from \"../theme/theme.js\";\n\n/**\n * The session chip: the session's name, filled with its colour, laid into the\n * top-right of the input box.\n *\n * The footer used to be the only place a session announced itself, at the tail of\n * its busiest line in its quietest colour. The chip puts the same fact where the\n * cursor already is, and gives it a colour so it can be recognised rather than\n * read — which is what you want when four terminals are open.\n *\n * This module owns the *rule* as well as the rendering, because two components\n * depend on it: the editor draws the chip, and the footer drops its own copy of\n * the name when the chip is showing. Both call `sessionChipFits`, so the name\n * cannot end up in neither place.\n */\n\n/**\n * Longest name the chip will show. Past this it truncates: a chip is a glance\n * target, and a name that eats half the border has stopped being one.\n */\nconst MAX_CHIP_NAME_WIDTH = 20;\n\n/**\n * Terminal width at which the chip is worth drawing at all. Below it the box has\n * more urgent things to spend columns on, and the footer keeps the name instead.\n *\n * The number is not arbitrary: with the name capped at 20 columns the chip is at\n * most 22 cells, and 48 columns leaves the editor's border enough room for the\n * chip, its inset, and a lead-in even with the scroll indicator also present — so\n * \"fits\" here and \"fits\" inside the editor agree.\n */\nexport const SESSION_CHIP_MIN_WIDTH = 48;\n\n/** Whether a chip is drawn at this terminal width. */\nexport function sessionChipFits(width: number): boolean {\n\treturn width >= SESSION_CHIP_MIN_WIDTH;\n}\n\n/**\n * Build the chip for a session. Returns the plain/styled pair the editor's top\n * border needs; the padding is part of the plain string too, so width math and\n * truncation stay honest.\n *\n * The fill carries the colour and the ink is picked from the fill's luminance, so\n * one call renders correctly on a dark theme's bright hues and a light theme's\n * deep ones alike. Themes whose palette entry cannot be filled fall back to an\n * outline chip — quieter, but never unreadable.\n */\nexport function renderSessionChip(name: string, colorSlot: number): EditorTopBorderLabel | undefined {\n\tconst trimmed = name.trim();\n\tif (!trimmed) return undefined;\n\tconst shown =\n\t\tvisibleWidth(trimmed) > MAX_CHIP_NAME_WIDTH ? truncateToWidth(trimmed, MAX_CHIP_NAME_WIDTH, \"…\") : trimmed;\n\tconst token = sessionColorToken(colorSlot);\n\tif (theme.canFill(token)) {\n\t\tconst plain = ` ${shown} `;\n\t\t// Bold is written as a raw SGR pair rather than through chalk so it\n\t\t// survives inside the fill's own colour run, matching how the tape chip\n\t\t// emits its label.\n\t\treturn { plain, styled: theme.fill(token, `\\x1b[1m${plain}\\x1b[22m`) };\n\t}\n\tconst plain = `┤${shown}├`;\n\treturn { plain, styled: theme.fg(\"border\", \"┤\") + theme.fg(token, shown) + theme.fg(\"border\", \"├\") };\n}\n"]}