export async function handleStructureKeyboardNavigation(e, { addNode, startRename }) {
    const activeElement = document.activeElement?.shadowRoot?.activeElement?.closest("eden-structure-tree-node");
    if ((e.ctrlKey || e.metaKey) && e.key === "p") {
        e.preventDefault();
        e.stopPropagation();
        await addNode();
    }
    if ((e.ctrlKey || e.metaKey) && e.key === "e") {
        e.preventDefault();
        e.stopPropagation();
        startRename();
    }
    if (activeElement) {
        const selectedLeaf = activeElement.querySelector(".structure-tree__node-label");
        const isEditing = selectedLeaf?.hasAttribute("contentEditable");
        if (isEditing)
            return;
        if (e.key === "ArrowRight") {
            e.preventDefault();
            activeElement.openNode();
        }
        if (e.key === "ArrowLeft") {
            e.preventDefault();
            activeElement.closeNode();
        }
    }
}
