/**
 * Copyright 2013-2026 the original author or authors from the JHipster project.
 *
 * This file is part of the JHipster project, see https://www.jhipster.tech/
 * for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { overrideMutateDataProperty, } from "../../lib/utils/object.js";
import { normalizePathEnd } from "../../lib/utils/path.js";
import { CLIENT_MAIN_SRC_DIR, CLIENT_TEST_SRC_DIR, JAVA_COMPATIBLE_VERSIONS, JHIPSTER_DEPENDENCIES_VERSION, RECOMMENDED_JAVA_VERSION, SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR, SERVER_TEST_RES_DIR, SERVER_TEST_SRC_DIR, } from "../generator-constants.js";
import { getMainClassName } from "../java/support/util.js";
import { GRAALVM_REACHABILITY_METADATA } from "./generators/graalvm/internal/constants.js";
export const mutateApplicationLoading = {
    __override__: false,
    javaCompatibleVersions: () => [...JAVA_COMPATIBLE_VERSIONS],
    entityPackages: () => [],
    javaDependencies: () => ({}),
    javaProperties: () => ({}),
    javaManagedProperties: () => ({}),
    packageInfoJavadocs: () => [],
    javaIntegrationTestExclude: () => [],
    domains: () => [],
};
export const mutateApplicationPreparing = {
    __override__: false,
    backendTypeJavaAny: true,
    javaVersion: RECOMMENDED_JAVA_VERSION,
    mainClass: ({ baseName }) => getMainClassName({ baseName }),
    packageName: 'com.mycompany.myapp',
    packageFolder: ({ packageName }) => `${packageName.replace(/\./g, '/')}/`,
    srcMainJava: SERVER_MAIN_SRC_DIR,
    srcMainResources: SERVER_MAIN_RES_DIR,
    srcMainWebapp: CLIENT_MAIN_SRC_DIR,
    srcTestJava: SERVER_TEST_SRC_DIR,
    srcTestResources: SERVER_TEST_RES_DIR,
    srcTestJavascript: CLIENT_TEST_SRC_DIR,
    javaPackageSrcDir: ({ srcMainJava, packageFolder }) => normalizePathEnd(`${srcMainJava}${packageFolder}`),
    javaPackageTestDir: ({ srcTestJava, packageFolder }) => normalizePathEnd(`${srcTestJava}${packageFolder}`),
    buildTool: 'maven',
    temporaryDir: ({ buildTool }) => {
        switch (buildTool) {
            case 'maven':
                return 'target/';
            case 'gradle':
                return 'build/';
            default:
                throw new Error(`Unknown build tool: ${buildTool}`);
        }
    },
    clientRootDir: '',
    clientSrcDir: ({ srcMainWebapp }) => srcMainWebapp,
    clientTestDir: ({ srcTestJavascript }) => srcTestJavascript,
    clientDistDir: ({ buildTool, temporaryDir }) => {
        switch (buildTool) {
            case 'maven':
                return `${temporaryDir}classes/static/`;
            case 'gradle':
                return `${temporaryDir}resources/main/static/`;
            default:
                return 'dist/';
        }
    },
    packageInfoJavadocs: overrideMutateDataProperty(({ packageInfoJavadocs, packageName }) => {
        packageInfoJavadocs.push({ packageName: `${packageName}.aop.logging`, documentation: 'Logging aspect.' }, { packageName: `${packageName}.management`, documentation: 'Application management.' }, { packageName: `${packageName}.repository.rowmapper`, documentation: 'Webflux database column mapper.' }, { packageName: `${packageName}.security`, documentation: 'Application security utilities.' }, { packageName: `${packageName}.service.dto`, documentation: 'Data transfer objects for rest mapping.' }, { packageName: `${packageName}.service.mapper`, documentation: 'Data transfer objects mappers.' }, { packageName: `${packageName}.web.filter`, documentation: 'Request chain filters.' }, { packageName: `${packageName}.web.rest.errors`, documentation: 'Rest layer error handling.' }, { packageName: `${packageName}.web.rest.vm`, documentation: 'Rest layer visual models.' });
        return packageInfoJavadocs;
    }),
    reactive: false,
    addOpenapiGeneratorPlugin: true,
    emptyOrReactive: ({ reactive }) => (reactive ? 'Reactive' : ''),
    imperativeOrReactive: ({ reactive }) => (reactive ? 'reactive' : 'imperative'),
    optionalOrMono: ({ reactive }) => (reactive ? 'Mono' : 'Optional'),
    optionalOrMonoOfNullable: ({ reactive }) => (reactive ? 'Mono.justOrEmpty' : 'Optional.ofNullable'),
    optionalOrMonoClassPath: ({ reactive }) => (reactive ? 'reactor.core.publisher.Mono' : 'java.util.Optional'),
    wrapMono: ctx => (className) => ctx.reactive ? `Mono<${className}>` : className,
    listOrFlux: ({ reactive }) => (reactive ? 'Flux' : 'List'),
    listOrFluxClassPath: ({ reactive }) => (reactive ? 'reactor.core.publisher.Flux' : 'java.util.List'),
    reactorBlock: ({ reactive }) => (reactive ? '.block()' : ''),
    reactorBlockOptional: ({ reactive }) => (reactive ? '.blockOptional()' : ''),
    pageOrFlux: ({ reactive }) => (reactive ? 'Flux' : 'Page'),
    jhipsterDependenciesVersion: JHIPSTER_DEPENDENCIES_VERSION,
    withGeneratedFlag: false,
    graalvmReachabilityMetadata: GRAALVM_REACHABILITY_METADATA,
};
