import { observeOnce } from "./_global--observer.js";
import { jsVar } from "./_global--enqueue-loader.js";




const webComponentLoadPromises = {};
function observeWebComponentsInDomRoot(domRoot) {
    for (const webComponentName of jsVar("neoGlobalWebComponentImporterWebComponents")) {
        if (webComponentLoadPromises[webComponentName]) { continue; }
        observeOnce(webComponentName, async (element) => {
            webComponentLoadPromises[webComponentName] ??= (async () => {
                const module = await import(`./_global-web-component-${webComponentName.replace("-neo-motion-beta", "")}.js`)
                if (!customElements.get(webComponentName)) { customElements.define(webComponentName, module.default); }
                document.getElementById("neo-web-component-hide-neo-motion-beta-" + webComponentName)?.remove();
            })();
            await webComponentLoadPromises[webComponentName];
            if (element.shadowRoot) { observeWebComponentsInDomRoot(element.shadowRoot); }
        }, { domRoot });
    }
}
observeWebComponentsInDomRoot(document.documentElement);
