export class TypeScriptMetaRenderer {
    disposeToolboxEntry(entry) {
        throw new Error('Method not implemented.');
    }
    renderToolboxEntry(mod, whitelist) {
        let definitionFile;
        // Legacy module signature
        if (mod.def.type && mod.def.type === 'blockly') {
            definitionFile = mod.def.typeScriptDefinition ? mod.def.typeScriptDefinition : '';
        }
        else {
            definitionFile = TypeScriptMetaRenderer.render(mod);
        }
        const category = {
            name: mod.getVerboseDisplay(),
            id: mod.def.type && mod.def.type === 'blockly' ? (mod.def.id || '') : mod.def.name,
            colour: mod.getColor(),
            definitionFile,
        };
        return category;
    }
    static render(m) {
        switch (m.def.type) {
            case 'module': {
                return TypeScriptMetaRenderer.renderModule(m);
            }
            case 'variable': {
                return TypeScriptMetaRenderer.renderVariable(m);
            }
            case 'function': {
                return TypeScriptMetaRenderer.renderFunction(m);
            }
            default: {
                break;
            }
        }
        return null;
    }
    static renderModule(m) {
        if (!m.symbols) {
            return '';
        }
        return `const ${m.def.name} = {
    ${m.symbols.map(sym => TypeScriptMetaRenderer.render(sym)).join('\n    ')}
};
`;
    }
    static renderVariable(m) {
        return `${m.def.name} : ${TypeScriptMetaRenderer.parseType(m.getReturnType())};`;
    }
    static renderParam(param) {
        return `${param.def.name} : ${TypeScriptMetaRenderer.parseType(param.getReturnType())}`;
    }
    static renderFunction(m) {
        return `${m.def.name}(${m.getParameters().map(param => TypeScriptMetaRenderer.renderParam(param)).join(', ')}) : ${TypeScriptMetaRenderer.parseType(m.getReturnType())};`;
    }
    static parseType(type) {
        if (!type) {
            return 'void';
        }
        switch (type) {
            case Number: {
                return 'number';
            }
            case String: {
                return 'string';
            }
            case Function: {
                return 'Function';
            }
            default: {
                return type;
            }
        }
    }
}
export default TypeScriptMetaRenderer;
//# sourceMappingURL=api-renderer.js.map