"use strict";
/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateSiteFiles = generateSiteFiles;
const utils_1 = require("@docusaurus/utils");
const codegenRoutes_1 = require("./codegenRoutes");
function genWarning({ generatedFilesDir }) {
    return (0, utils_1.generate)(generatedFilesDir, 
    // cSpell:ignore DONT
    'DONT-EDIT-THIS-FOLDER', `This folder stores temp files that Docusaurus' client bundler accesses.

DO NOT hand-modify files in this folder because they will be overwritten in the
next build. You can clear all build artifacts (including this folder) with the
\`docusaurus clear\` command.
`);
}
function genSiteConfig({ generatedFilesDir, siteConfig, }) {
    return (0, utils_1.generate)(generatedFilesDir, `${utils_1.DEFAULT_CONFIG_FILE_NAME}.mjs`, `/*
 * AUTOGENERATED - DON'T EDIT
 * Your edits in this file will be overwritten in the next build!
 * Modify the docusaurus.config.js file at your site's root instead.
 */
export default ${JSON.stringify(siteConfig, null, 2)};
`);
}
function genClientModules({ generatedFilesDir, clientModules, }) {
    return (0, utils_1.generate)(generatedFilesDir, 'client-modules.js', `export default [
${clientModules
        // Use `require()` because `import()` is async but client modules can have CSS
        // and the order matters for loading CSS.
        .map((clientModule) => `  require("${(0, utils_1.escapePath)(clientModule)}"),`)
        .join('\n')}
];
`);
}
function genGlobalData({ generatedFilesDir, globalData, }) {
    return (0, utils_1.generate)(generatedFilesDir, 'globalData.json', JSON.stringify(globalData, null, 2));
}
function genI18n({ generatedFilesDir, i18n, }) {
    return (0, utils_1.generate)(generatedFilesDir, 'i18n.json', JSON.stringify(i18n, null, 2));
}
function genCodeTranslations({ generatedFilesDir, codeTranslations, }) {
    return (0, utils_1.generate)(generatedFilesDir, 'codeTranslations.json', JSON.stringify(codeTranslations, null, 2));
}
function genSiteMetadata({ generatedFilesDir, siteMetadata, }) {
    return (0, utils_1.generate)(generatedFilesDir, 'site-metadata.json', JSON.stringify(siteMetadata, null, 2));
}
function genSiteStorage({ generatedFilesDir, siteStorage, }) {
    return (0, utils_1.generate)(generatedFilesDir, 'site-storage.json', JSON.stringify(siteStorage, null, 2));
}
async function generateSiteFiles(params) {
    await Promise.all([
        genWarning(params),
        genClientModules(params),
        genSiteConfig(params),
        (0, codegenRoutes_1.generateRouteFiles)(params),
        genGlobalData(params),
        genSiteMetadata(params),
        genSiteStorage(params),
        genI18n(params),
        genCodeTranslations(params),
    ]);
}
