import { angularReservedKeywords } from '../../generators/angular/support/reserved-keywords.js';
import { mysqlReservedKeywords } from '../../generators/spring-data-relational/support/mysql-reserved-keywords.js';
import { javaReservedKeywords } from '../../generators/java/support/reserved-keywords.js';
import { typescriptReservedKeywords } from '../../generators/client/support/typescript.js';
import { postgresqlReservedKeywords } from '../../generators/spring-data-relational/support/postgresql-reserved-keywords.js';
import { cassandraReservedKeywords } from '../../generators/spring-data-cassandra/support/reserved-keywords.js';
import { couchbaseReservedKeywords } from '../../generators/spring-data-couchbase/support/reserved-keywords.js';
import { oracleReservedKeywords } from '../../generators/spring-data-relational/support/oracle-reserved-keywords.js';
import { mssqlReservedKeywords } from '../../generators/spring-data-relational/support/mssql-reserved-keywords.js';
import { neo4jReservedKeywords } from '../../generators/spring-data-neo4j/support/reserved-keywords.js';
import PagingReservedKeywords from './reserved-keywords/paging.js';
import JHipsterReservedKeywords from './reserved-keywords/jhipster.js';
import applicationOptions from './application-options.js';
const clientFrameworks = applicationOptions.OptionValues[applicationOptions.OptionNames.CLIENT_FRAMEWORK];
const ReservedWords = {
    JHIPSTER: JHipsterReservedKeywords,
    ANGULAR: angularReservedKeywords,
    REACT: [],
    JAVA: javaReservedKeywords,
    TYPESCRIPT: typescriptReservedKeywords,
    MYSQL: mysqlReservedKeywords,
    MARIADB: mysqlReservedKeywords,
    POSTGRESQL: postgresqlReservedKeywords,
    PAGING: PagingReservedKeywords,
    CASSANDRA: cassandraReservedKeywords,
    COUCHBASE: couchbaseReservedKeywords,
    ORACLE: oracleReservedKeywords,
    MONGODB: ['DOCUMENT'],
    MSSQL: mssqlReservedKeywords,
    NEO4J: neo4jReservedKeywords,
};
export const keywordsForType = (type) => ReservedWords[type.toUpperCase()];
export function isReserved(keyword, type) {
    return !!keyword && !!type && !!keywordsForType(type)?.includes(keyword.toUpperCase());
}
export function isReservedClassName(keyword) {
    return (isReserved(keyword, 'JHIPSTER') || isReserved(keyword, 'ANGULAR') || isReserved(keyword, 'TYPESCRIPT') || isReserved(keyword, 'JAVA'));
}
export function isReservedTableName(keyword, databaseType) {
    return databaseType.toUpperCase() === 'SQL'
        ? isReserved(keyword, 'MYSQL') || isReserved(keyword, 'POSTGRESQL') || isReserved(keyword, 'ORACLE') || isReserved(keyword, 'MSSQL')
        : isReserved(keyword, databaseType);
}
export function isReservedPaginationWords(keyword) {
    return isReserved(keyword, 'PAGING');
}
export function isReservedFieldName(keyword, clientFramework) {
    if (clientFramework) {
        if (clientFramework === clientFrameworks.angular) {
            return isReserved(keyword, 'ANGULAR') || isReserved(keyword, 'TYPESCRIPT') || isReserved(keyword, 'JAVA');
        }
        if (clientFramework === clientFrameworks.react) {
            return isReserved(keyword, 'TYPESCRIPT') || isReserved(keyword, 'JAVA');
        }
    }
    return isReserved(keyword, 'ANGULAR') || isReserved(keyword, 'TYPESCRIPT') || isReserved(keyword, 'JAVA');
}
export default {
    isReserved,
    isReservedClassName,
    isReservedTableName,
    isReservedFieldName,
    isReservedPaginationWords,
    JHIPSTER: ReservedWords.JHIPSTER,
    ANGULAR: ReservedWords.ANGULAR,
    REACT: ReservedWords.REACT,
    JAVA: ReservedWords.JAVA,
    TYPESCRIPT: ReservedWords.TYPESCRIPT,
    MYSQL: ReservedWords.MYSQL,
    POSTGRESQL: ReservedWords.POSTGRESQL,
    CASSANDRA: ReservedWords.CASSANDRA,
    COUCHBASE: ReservedWords.COUCHBASE,
    ORACLE: ReservedWords.ORACLE,
    MONGODB: ReservedWords.MONGODB,
    MSSQL: ReservedWords.MSSQL,
    NEO4J: ReservedWords.NEO4J,
};
