/**
 * Normalizes a string to be used as an identifier
 * - Converts to lowercase
 * - Replaces spaces and special characters with hyphens
 * - Removes consecutive hyphens
 * - Trims leading/trailing hyphens
 */
export const normalizeToId = (str) => {
    return str
        .toLowerCase()
        .replace(/\s+/g, '-') // Replace spaces with hyphens
        .replace(/[^a-z0-9-]/g, '-') // Replace special characters with hyphens
        .replace(/-+/g, '-') // Replace consecutive hyphens with single hyphen
        .replace(/^-+|-+$/g, ''); // Remove leading and trailing hyphens
};
/**
 * Generates a menu item ID from title and level
 */
export const generateMenuItemId = (title, level = 0) => {
    const normalizedTitle = normalizeToId(title);
    return normalizedTitle ? `${normalizedTitle}-${level}` : `item-${level}`;
};
//# sourceMappingURL=string.js.map