/**
 * Syntect-based syntax highlighting via N-API, with JS fallback.
 *
 * When native addon is available: ANSI-colored output using semantic scope
 * matching across 11 token categories.
 * When unavailable: returns code unmodified (no highlighting).
 */
import { native } from "../native.js";
// ── Native availability check ─────────────────────────────────────────────────
let _nativeAvailable = null;
function nativeAvailable() {
    if (_nativeAvailable === null) {
        try {
            native.supportsLanguage("javascript");
            _nativeAvailable = true;
        }
        catch {
            _nativeAvailable = false;
        }
    }
    return _nativeAvailable;
}
/**
 * Highlight source code and return ANSI-colored output.
 * Falls back to returning code unmodified when native addon unavailable.
 */
export function highlightCode(code, lang, colors) {
    if (nativeAvailable()) {
        return native.highlightCode(code, lang, colors);
    }
    // No highlighting without native — return code as-is
    return code;
}
/**
 * Check if a language is supported for highlighting.
 * Returns false when native addon unavailable.
 */
export function supportsLanguage(lang) {
    if (nativeAvailable()) {
        return native.supportsLanguage(lang);
    }
    return false;
}
/**
 * Get list of all supported language names.
 * Returns empty array when native addon unavailable.
 */
export function getSupportedLanguages() {
    if (nativeAvailable()) {
        return native.getSupportedLanguages();
    }
    return [];
}
