const FUNC_DEF_RE = /^def\s+(\w+)\s*\(/gm;
const CLASS_DEF_RE = /^class\s+(\w+)/gm;
const IMPORT_RE = /^(?:from\s+(\S+)\s+)?import\s+(.+)/gm;
const TOP_LEVEL_ASSIGN_RE = /^([A-Z_][A-Z_\d]*)\s*=/gm;
export function extractExports(source) {
    const exports = [];
    let match;
    const funcRe = new RegExp(FUNC_DEF_RE.source, 'gm');
    while ((match = funcRe.exec(source)) !== null) {
        if (!match[1].startsWith('_')) {
            exports.push({ name: match[1], type: 'function' });
        }
    }
    const classRe = new RegExp(CLASS_DEF_RE.source, 'gm');
    while ((match = classRe.exec(source)) !== null) {
        if (!match[1].startsWith('_')) {
            exports.push({ name: match[1], type: 'class' });
        }
    }
    const constRe = new RegExp(TOP_LEVEL_ASSIGN_RE.source, 'gm');
    while ((match = constRe.exec(source)) !== null) {
        exports.push({ name: match[1], type: 'constant' });
    }
    return exports;
}
export function extractImports(source) {
    const external = [];
    const internal = [];
    let match;
    const importRe = new RegExp(IMPORT_RE.source, 'gm');
    while ((match = importRe.exec(source)) !== null) {
        const module = match[1] ?? match[2].trim().split(/\s*,\s*/)[0];
        if (module.startsWith('.')) {
            internal.push(module);
        }
        else {
            external.push(module);
        }
    }
    return { external, internal };
}
export function hasTypeAnnotations(source) {
    return /:\s*\w+/.test(source) && /->/.test(source);
}
//# sourceMappingURL=python.js.map