import { isDigit } from "unicode-properties";
import { funPrefixNamer } from "../../Naming.js";
import { allLowerWordStyle, allUpperWordStyle, combineWords, firstUpperWordStyle, isLetterOrUnderscore, isNumeric, legalizeCharacters, splitIntoWords, } from "../../support/Strings.js";
import { invalidSymbols, keywords } from "./constants.js";
/**
 * Check if given parameter name should be wrapped in a backtick
 * @param paramName
 */
export const shouldAddBacktick = (paramName) => {
    return (keywords.some((s) => paramName === s) ||
        invalidSymbols.some((s) => paramName.includes(s)) ||
        !isNaN(Number.parseFloat(paramName)) ||
        !isNaN(Number.parseInt(paramName.charAt(0))));
};
function isPartCharacter(codePoint) {
    return isLetterOrUnderscore(codePoint) || isNumeric(codePoint);
}
function isStartCharacter(codePoint) {
    return isPartCharacter(codePoint) && !isDigit(codePoint);
}
const legalizeName = legalizeCharacters(isPartCharacter);
export function scalaNameStyle(isUpper, original) {
    const words = splitIntoWords(original);
    return combineWords(words, legalizeName, isUpper ? firstUpperWordStyle : allLowerWordStyle, firstUpperWordStyle, isUpper ? allUpperWordStyle : allLowerWordStyle, allUpperWordStyle, "", isStartCharacter);
}
export const upperNamingFunction = funPrefixNamer("upper", (s) => scalaNameStyle(true, s));
export const lowerNamingFunction = funPrefixNamer("lower", (s) => scalaNameStyle(false, s));
