const PATH_SEPARATOR = " \u25b8 ";
const POSITION_SEPARATOR = " \u00b7 ";
const PARENT_GUID_PATTERN = /\{?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\}?/g;
const EDGE_SEPARATOR_PATTERN = /^[\s_.-]+|[\s_.-]+$/g;
export function buildInsertTargetLabel({ placeholder, description, index, }) {
    const segments = getAncestorComponentSegments(placeholder.parentComponent);
    segments.push(formatPlaceholderDisplayName(description || placeholder.name));
    return `${segments.join(PATH_SEPARATOR)}${POSITION_SEPARATOR}${index + 1}`;
}
export function formatPlaceholderDisplayName(name) {
    const formatted = name
        .replace(PARENT_GUID_PATTERN, "")
        .replace(/_{2,}/g, "_")
        .replace(/\.{2,}/g, ".")
        .replace(/-{2,}/g, "-")
        .replace(/\s{2,}/g, " ")
        .replace(EDGE_SEPARATOR_PATTERN, "")
        .trim();
    return formatted || name;
}
function getAncestorComponentSegments(parentComponent) {
    const segments = [];
    let component = parentComponent;
    while (component) {
        const parentPlaceholder = component.parentPlaceholder;
        if (!parentPlaceholder)
            break;
        segments.unshift(component.name);
        component = parentPlaceholder.parentComponent;
    }
    segments.unshift("Page");
    return segments;
}
//# sourceMappingURL=insertTargetLabel.js.map