{"version":3,"file":"colorizer.mjs","names":[],"sources":["../../src/output/colorizer.ts"],"sourcesContent":["// ANSI color/style codes\nconst ansiCodes: Record<AnsiStyle, string> = {\n  reset: '\\x1b[0m',\n  bold: '\\x1b[1m',\n  dim: '\\x1b[2m',\n  italic: '\\x1b[3m',\n  underline: '\\x1b[4m',\n  strikethrough: '\\x1b[9m',\n  red: '\\x1b[31m',\n  green: '\\x1b[32m',\n  yellow: '\\x1b[33m',\n  blue: '\\x1b[34m',\n  magenta: '\\x1b[35m',\n  cyan: '\\x1b[36m',\n  white: '\\x1b[37m',\n  gray: '\\x1b[90m',\n};\n\n/**\n * Available ANSI styles that can be combined for each color role.\n */\nexport type AnsiStyle =\n  | 'reset'\n  | 'bold'\n  | 'dim'\n  | 'italic'\n  | 'underline'\n  | 'strikethrough'\n  | 'red'\n  | 'green'\n  | 'yellow'\n  | 'blue'\n  | 'magenta'\n  | 'cyan'\n  | 'white'\n  | 'gray';\n\n/**\n * Maps each semantic color role to an array of ANSI styles.\n * Partial configs are merged with the default theme.\n */\nexport type ColorConfig = {\n  command?: AnsiStyle[];\n  arg?: AnsiStyle[];\n  type?: AnsiStyle[];\n  description?: AnsiStyle[];\n  label?: AnsiStyle[];\n  meta?: AnsiStyle[];\n  example?: AnsiStyle[];\n  exampleValue?: AnsiStyle[];\n  deprecated?: AnsiStyle[];\n};\n\nexport type Colorizer = {\n  command: (text: string) => string;\n  arg: (text: string) => string;\n  type: (text: string) => string;\n  description: (text: string) => string;\n  label: (text: string) => string;\n  meta: (text: string) => string;\n  example: (text: string) => string;\n  exampleValue: (text: string) => string;\n  deprecated: (text: string) => string;\n};\n\n// ============================================================================\n// Predefined Themes\n// ============================================================================\n\nconst defaultTheme: Required<ColorConfig> = {\n  command: ['cyan', 'bold'],\n  arg: ['green'],\n  type: ['yellow'],\n  description: ['dim'],\n  label: ['bold'],\n  meta: ['gray'],\n  example: ['underline'],\n  exampleValue: ['italic'],\n  deprecated: ['strikethrough', 'gray'],\n};\n\nconst oceanTheme: Required<ColorConfig> = {\n  command: ['blue', 'bold'],\n  arg: ['cyan'],\n  type: ['green'],\n  description: ['dim'],\n  label: ['bold'],\n  meta: ['gray'],\n  example: ['underline', 'cyan'],\n  exampleValue: ['italic'],\n  deprecated: ['strikethrough', 'gray'],\n};\n\nconst warmTheme: Required<ColorConfig> = {\n  command: ['yellow', 'bold'],\n  arg: ['red'],\n  type: ['magenta'],\n  description: ['dim'],\n  label: ['bold'],\n  meta: ['gray'],\n  example: ['underline', 'yellow'],\n  exampleValue: ['italic'],\n  deprecated: ['strikethrough', 'gray'],\n};\n\nconst monochromeTheme: Required<ColorConfig> = {\n  command: ['bold'],\n  arg: ['underline'],\n  type: ['dim'],\n  description: ['dim'],\n  label: ['bold'],\n  meta: ['dim'],\n  example: ['underline'],\n  exampleValue: ['italic'],\n  deprecated: ['strikethrough', 'dim'],\n};\n\n/**\n * Available predefined color themes.\n */\nexport type ColorTheme = 'default' | 'ocean' | 'warm' | 'monochrome';\n\nexport const colorThemes: Record<ColorTheme, Required<ColorConfig>> = {\n  default: defaultTheme,\n  ocean: oceanTheme,\n  warm: warmTheme,\n  monochrome: monochromeTheme,\n};\n\nfunction makeStyleFn(styles: AnsiStyle[]): (text: string) => string {\n  const prefix = styles.map((s) => ansiCodes[s]).join('');\n  return (text: string) => `${prefix}${text}${ansiCodes.reset}`;\n}\n\nfunction resolveConfig(config?: ColorTheme | ColorConfig): Required<ColorConfig> {\n  if (!config) return defaultTheme;\n  if (typeof config === 'string') return colorThemes[config] ?? defaultTheme;\n  return { ...defaultTheme, ...config };\n}\n\nexport function createColorizer(config?: ColorTheme | ColorConfig): Colorizer {\n  const resolved = resolveConfig(config);\n  return {\n    command: makeStyleFn(resolved.command),\n    arg: makeStyleFn(resolved.arg),\n    type: makeStyleFn(resolved.type),\n    description: makeStyleFn(resolved.description),\n    label: makeStyleFn(resolved.label),\n    meta: makeStyleFn(resolved.meta),\n    example: makeStyleFn(resolved.example),\n    exampleValue: makeSty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