import qs from "qs";
function isRecordLike(value) {
    return typeof value === "object";
}
export function processStringFields(value) {
    if (!value)
        return value;
    if (Array.isArray(value)) {
        return value.map((item) => processStringFields(item));
    }
    if (!isRecordLike(value)) {
        return value;
    }
    return Object.fromEntries(Object.entries(value).map((entry) => {
        const [key, value] = entry;
        if (key.endsWith("_boolean")) {
            return [key.replace(/_boolean$/, ""), isBooleanLike(value)];
        }
        return [key, processStringFields(value)];
    }));
}
function isBooleanLike(value) {
    return value === "1" || value === "true" || value === "on";
}
export function parseStringFields(string) {
    const parsed = qs.parse(string, {
        allowDots: true,
    });
    return processStringFields(parsed);
}
//# sourceMappingURL=body-parser.js.map