{"version":3,"file":"ansi.mjs","names":[],"sources":["../../src/formatters/ansi.ts"],"sourcesContent":["import type { Diagnostic } from '../diagnostic'\n\nexport interface Colors {\n  red: (s: string) => string\n  yellow: (s: string) => string\n  cyan: (s: string) => string\n  gray: (s: string) => string\n  bold: (s: string) => string\n  dim: (s: string) => string\n}\n\nexport function ansiFormatter(colors: Colors): (d: Diagnostic) => string {\n  return (d) => {\n    const tag = colors.bold(colors.red(`[${d.name}]`))\n    const header = `${tag} ${d.message}`\n\n    const details: string[] = []\n    if (d.fix)\n      details.push(`${colors.dim('fix:')} ${d.fix}`)\n    if (d.sources?.length)\n      details.push(`${colors.dim('sources:')} ${d.sources.join(', ')}`)\n    if (d.docs)\n      details.push(`${colors.dim('see:')} ${colors.cyan(d.docs)}`)\n\n    if (details.length === 0)\n      return header\n\n    const lines = details.map((detail, i) => {\n      const connector = colors.dim(i < details.length - 1 ? '├▶' : '╰▶')\n      return `${connector} ${detail}`\n    })\n    return [header, ...lines].join('\\n')\n  }\n}\n"],"mappings":";AAWA,SAAgB,cAAc,QAA2C;CACvE,QAAQ,MAAM;EAEZ,MAAM,SAAS,GADH,OAAO,KAAK,OAAO,IAAI,IAAI,EAAE,KAAK,GAAG,CAC5B,CAAC,GAAG,EAAE;EAE3B,MAAM,UAAoB,EAAE;EAC5B,IAAI,EAAE,KACJ,QAAQ,KAAK,GAAG,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE,MAAM;EAChD,IAAI,EAAE,SAAS,QACb,QAAQ,KAAK,GAAG,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,QAAQ,KAAK,KAAK,GAAG;EACnE,IAAI,EAAE,MACJ,QAAQ,KAAK,GAAG,OAAO,IAAI,OAAO,CAAC,GAAG,OAAO,KAAK,EAAE,KAAK,GAAG;EAE9D,IAAI,QAAQ,WAAW,GACrB,OAAO;EAMT,OAAO,CAAC,QAAQ,GAJF,QAAQ,KAAK,QAAQ,MAAM;GAEvC,OAAO,GADW,OAAO,IAAI,IAAI,QAAQ,SAAS,IAAI,OAAO,KAC1C,CAAC,GAAG;IAED,CAAC,CAAC,KAAK,KAAK"}