"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringEscape = void 0;
exports.phpNameStyle = phpNameStyle;
const Strings_js_1 = require("../../support/Strings.js");
exports.stringEscape = (0, Strings_js_1.utf16ConcatMap)((0, Strings_js_1.escapeNonPrintableMapper)(Strings_js_1.isAscii, Strings_js_1.standardUnicodeHexEscape));
function isStartCharacter(codePoint) {
    if (codePoint === 0x5f)
        return true; // underscore
    return (0, Strings_js_1.isAscii)(codePoint) && (0, Strings_js_1.isLetter)(codePoint);
}
function isPartCharacter(codePoint) {
    return (isStartCharacter(codePoint) ||
        ((0, Strings_js_1.isAscii)(codePoint) && (0, Strings_js_1.isDigit)(codePoint)));
}
const legalizeName = (0, Strings_js_1.utf16LegalizeCharacters)(isPartCharacter);
function phpNameStyle(startWithUpper, upperUnderscore, original, acronymsStyle = Strings_js_1.allUpperWordStyle) {
    const words = (0, Strings_js_1.splitIntoWords)(original);
    return (0, Strings_js_1.combineWords)(words, legalizeName, upperUnderscore
        ? Strings_js_1.allUpperWordStyle
        : startWithUpper
            ? Strings_js_1.firstUpperWordStyle
            : Strings_js_1.allLowerWordStyle, upperUnderscore ? Strings_js_1.allUpperWordStyle : Strings_js_1.firstUpperWordStyle, upperUnderscore || startWithUpper
        ? Strings_js_1.allUpperWordStyle
        : Strings_js_1.allLowerWordStyle, acronymsStyle, upperUnderscore ? "_" : "", isStartCharacter);
}
