"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LanguageSwitchAssistant = void 0;
class LanguageSwitchAssistant {
    guides = new Map();
    constructor() {
        this.initGuides();
    }
    getGuide(from, to) {
        const key = `${from}→${to}`;
        return this.guides.get(key) || null;
    }
    getGotchas(from, to) {
        const guide = this.getGuide(from, to);
        return guide?.gotchas || [];
    }
    translateStyle(style, from, to) {
        const guide = this.getGuide(from, to);
        if (!guide)
            return style;
        for (const [fromPattern, toPattern] of Object.entries(guide.syntaxMap)) {
            const escaped = fromPattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
            const wordStart = /^\w/.test(fromPattern) ? '\\b' : '';
            const wordEnd = /\w$/.test(fromPattern) ? '\\b' : '';
            style = style.replace(new RegExp(`${wordStart}${escaped}${wordEnd}`, 'g'), toPattern);
        }
        return style;
    }
    getStyleTips(from, to) {
        const guide = this.getGuide(from, to);
        return guide?.styleTips || [];
    }
    getAvailableTransitions() {
        return Array.from(this.guides.keys());
    }
    initGuides() {
        this.guides.set('typescript→python', {
            from: 'TypeScript',
            to: 'Python',
            gotchas: [
                'Python uses indentation for blocks, not braces {}',
                'No const/let — variables are mutable by default',
                'Use snake_case not camelCase',
                'No type annotations required (but optional with mypy)',
                'List comprehensions instead of .map()/.filter()',
                'Use None instead of null/undefined',
                'Async uses async/await with asyncio, not Promise-based',
            ],
            syntaxMap: {
                'const ': '',
                'let ': '',
                'function ': 'def ',
                'console.log': 'print',
                '=== ': '== ',
                '!== ': '!= ',
                '&&': 'and',
                '||': 'or',
                '!': 'not ',
                'null': 'None',
                'undefined': 'None',
                '//': '#',
            },
            styleTips: [
                'Use list comprehensions: [x for x in items if x > 0]',
                'Use with statements for file handling',
                'Prefer dataclasses for simple data objects',
                'Use type hints with mypy for better IDE support',
            ],
        });
        this.guides.set('typescript→rust', {
            from: 'TypeScript',
            to: 'Rust',
            gotchas: [
                'Rust has ownership and borrowing — no garbage collector',
                'Variables are immutable by default (use mut)',
                'Use Result<T,E> instead of try/catch',
                'No null — use Option<T>',
                'Pattern matching with match instead of switch',
                'Traits instead of interfaces',
                'Cargo instead of npm',
            ],
            syntaxMap: {
                'const ': 'let ',
                'let ': 'let mut ',
                'function ': 'fn ',
                'console.log': 'println!',
                '=== ': '== ',
                'interface ': 'trait ',
                'class ': 'struct ',
            },
            styleTips: [
                'Use Result for fallible operations',
                'Prefer &str over String for parameters',
                'Use #[derive] for common trait implementations',
                'Leverage the type system — make invalid states unrepresentable',
            ],
        });
    }
}
exports.LanguageSwitchAssistant = LanguageSwitchAssistant;
//# sourceMappingURL=language-switch-assistant.js.map