"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
0 && (module.exports = {
    getBabelLoader: null,
    getReactCompilerLoader: null
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    getBabelLoader: function() {
        return getBabelLoader;
    },
    getReactCompilerLoader: function() {
        return getReactCompilerLoader;
    }
});
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const getReactCompilerPlugins = (options, isDev)=>{
    if (!options) {
        return undefined;
    }
    const compilerOptions = typeof options === 'boolean' ? {} : options;
    if (options) {
        return [
            [
                'babel-plugin-react-compiler',
                {
                    panicThreshold: isDev ? undefined : 'NONE',
                    ...compilerOptions
                }
            ]
        ];
    }
    return undefined;
};
const getBabelLoader = (useSWCLoader, babelConfigFile, isServer, distDir, pagesDir, cwd, srcDir, dev, isClient, reactCompilerOptions)=>{
    if (!useSWCLoader) {
        return {
            loader: require.resolve('./babel/loader/index'),
            options: {
                transformMode: 'default',
                configFile: babelConfigFile,
                isServer,
                distDir,
                pagesDir,
                cwd,
                srcDir: _path.default.dirname(srcDir),
                development: dev,
                hasReactRefresh: dev && isClient,
                hasJsxRuntime: true,
                plugins: getReactCompilerPlugins(reactCompilerOptions, dev)
            }
        };
    }
    return undefined;
};
/**
 * Get a separate babel loader for the react compiler, only used if Babel is not
 * configured through e.g. .babelrc. If user have babel config, this should be configured in the babel loader itself.
 * Note from react compiler:
 * > For best results, compiler must run as the first plugin in your Babel pipeline so it receives input as close to the original source as possible.
 */ const getReactCompilerLoader = (options, cwd, isDev)=>{
    if (!options) {
        return undefined;
    }
    return {
        loader: require.resolve('./babel/loader/index'),
        options: {
            transformMode: 'standalone',
            cwd,
            plugins: getReactCompilerPlugins(options, isDev)
        }
    };
};

//# sourceMappingURL=get-babel-loader-config.js.map