/** Pure string case-conversion utilities. No prototype pollution — call as functions. */
import { camelCase, flow, kebabCase, snakeCase, upperFirst } from 'lodash-es';
const WORD_SEPARATORS = /[\s\-_./]+/;
const CAMEL_BOUNDARY = /([a-z\d])([A-Z])/g;
function words(input) {
    return String(input ?? '')
        .replaceAll(CAMEL_BOUNDARY, '$1 $2')
        .split(WORD_SEPARATORS)
        .filter(Boolean)
        .map((w) => w.toLowerCase());
}
/** my-app-name */
export function toKebabCase(input) {
    return kebabCase(input);
}
/** myAppName */
export function toCamelCase(input) {
    return camelCase(input);
}
/** MyAppName */
export function toPascalCase(input) {
    return flow(camelCase, upperFirst)(input);
}
/** my_app_name */
export function toSnakeCase(input) {
    return snakeCase(input);
}
/** MY_APP_NAME */
export function toUpperSnakeCase(input) {
    return words(input)
        .map((w) => w.toUpperCase())
        .join('_');
}
export function first(arr) {
    return arr[0];
}
export function last(arr) {
    return arr.at(-1);
}
/** Strip 'I18n' from `text` when `i18n` is true. */
export function replaceI18n(text, i18n) {
    return i18n ? text.replaceAll('I18n', '') : text;
}
/** Ternary expressed as a function: `ternary(condition, trueVal, falseVal)`. */
export function ternary(condition, trueVal, falseVal) {
    return condition ? trueVal : falseVal;
}
/**
 * Prepend `spaces` columns of indentation to every non-empty line of `text`.
 *
 * Used by partials that include other partials whose output is emitted from
 * column 0 (the partial does not know its caller's nesting level). The caller
 * passes the rendered include through `indent()` to align it with the
 * surrounding HTML in the wrapper template.
 *
 * Empty lines are left untouched to avoid introducing trailing whitespace.
 */
export function indent(text, spaces) {
    if (spaces <= 0)
        return text;
    const prefix = ' '.repeat(spaces);
    return text
        .split('\n')
        .map((line) => (line.length === 0 ? line : prefix + line))
        .join('\n');
}
