"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const prettier_1 = tslib_1.__importDefault(require("prettier"));
const parser_babel_1 = tslib_1.__importDefault(require("prettier/parser-babel"));
const parser_postcss_1 = tslib_1.__importDefault(require("prettier/parser-postcss"));
const prettier_plugin_vue_1 = tslib_1.__importDefault(require("prettier-plugin-vue"));
const parser_html_1 = tslib_1.__importDefault(require("prettier/parser-html"));
const PARSERS = ['css', 'scss', 'less', 'json', 'html', 'vue'];
const factory = (config) => {
    const cfg = Object.assign({ customFileTypeParser: {} }, config);
    const codePrettier = (content, fileType) => {
        let parser;
        if (fileType === 'js' || fileType === 'jsx' || fileType === 'ts' || fileType === 'tsx') {
            parser = 'babel-ts';
        }
        else if (fileType === 'vue') {
            parser = 'vue';
        }
        else if (fileType === 'json') {
            parser = 'json-stringify';
        }
        else if (PARSERS.indexOf(fileType) >= 0) {
            parser = fileType;
        }
        else if (cfg.customFileTypeParser[fileType]) {
            parser = cfg.customFileTypeParser[fileType];
        }
        else {
            return content;
        }
        return prettier_1.default.format(content, {
            parser,
            plugins: [parser_babel_1.default, parser_postcss_1.default, prettier_plugin_vue_1.default, parser_html_1.default, ...(cfg.plugins || [])],
            singleQuote: true,
            jsxSingleQuote: false,
            htmlWhitespaceSensitivity: 'ignore',
            jsxBracketSameLine: false,
            vueIndentScriptAndStyle: false
        });
    };
    return codePrettier;
};
exports.default = factory;
//# sourceMappingURL=index.js.map