/**
 * Searches for an element with the given ID in parent shadow roots
 */
export function findElementInShadowRoots(id, from) {
    // First try to find in document
    const rootElm = document.getElementById(id);
    if (rootElm) {
        return rootElm;
    }
    // If not found in document, search in parent shadow roots
    let current = from;
    const queryId = `#${id}`;
    while (current) {
        // Check if current element has a shadow root and search within it
        if (current.shadowRoot) {
            const element = current.shadowRoot.querySelector(queryId);
            if (element) {
                return element;
            }
        }
        // Move up the DOM tree
        if (current.parentNode) {
            if (current.parentNode.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
                // We're inside a shadow root, move to the shadow host
                const shadowRoot = current.parentNode;
                current = shadowRoot.host;
            }
            else {
                // Regular DOM traversal
                current = current.parentElement;
            }
        }
        else {
            // No more parents
            current = null;
        }
    }
    return null;
}
//# sourceMappingURL=Dom.js.map