"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    registerAutoloader: ()=>registerAutoloader
});
const lazy_index_cjs_namespaceObject = require("../components/lazy-index.cjs");
var lazy_index_cjs_default = /*#__PURE__*/ __webpack_require__.n(lazy_index_cjs_namespaceObject);
function registerAutoloader(roots) {
    if ("u" < typeof window) return;
    roots ??= [
        document.documentElement
    ];
    roots = Array.isArray(roots) ? roots : [
        roots
    ];
    const visitedNodes = new WeakSet();
    const observeStencilElementHydration = (atomicElement)=>{
        const attributeObserver = new MutationObserver(async ()=>{
            if (atomicElement.classList.contains('hydrated') && 'shadowRoot' in atomicElement && atomicElement.shadowRoot && !visitedNodes.has(atomicElement.shadowRoot)) {
                attributeObserver.disconnect();
                await discover(atomicElement.shadowRoot);
                observer.observe(atomicElement.shadowRoot, {
                    subtree: true,
                    childList: true
                });
            }
        });
        attributeObserver.observe(atomicElement, {
            attributes: true,
            attributeFilter: [
                'class'
            ]
        });
    };
    const discover = async (root)=>{
        visitedNodes.add(root);
        const rootTagName = root instanceof Element ? root.tagName.toLowerCase() : '';
        const rootIsCustomElement = rootTagName?.includes('-');
        const allCustomElements = [
            ...root.querySelectorAll('*')
        ].filter((el)=>el.tagName.toLowerCase().includes('-'));
        if (rootIsCustomElement && root instanceof Element && !customElements.get(rootTagName) && !allCustomElements.includes(root)) allCustomElements.push(root);
        if (rootIsCustomElement) {
            if ('shadowRoot' in root && root.shadowRoot && !visitedNodes.has(root.shadowRoot)) {
                await discover(root.shadowRoot);
                observer.observe(root.shadowRoot, {
                    subtree: true,
                    childList: true
                });
            }
        }
        const childTemplates = root.querySelectorAll('template');
        for (const template of childTemplates)if (!visitedNodes.has(template.content)) {
            await discover(template.content);
            observer.observe(template.content, {
                subtree: true,
                childList: true
            });
        }
        const litRegistrationPromises = [];
        for (const atomicElement of allCustomElements){
            const tagName = atomicElement.tagName.toLowerCase();
            if (tagName in lazy_index_cjs_default() && !customElements.get(tagName)) {
                litRegistrationPromises.push(register(tagName));
                continue;
            }
            if ('shadowRoot' in atomicElement && atomicElement.shadowRoot && !visitedNodes.has(atomicElement.shadowRoot)) {
                await discover(atomicElement);
                continue;
            }
            if (!atomicElement.classList.contains('hydrated')) observeStencilElementHydration(atomicElement);
        }
        await Promise.allSettled(litRegistrationPromises);
        customElements.upgrade(root);
    };
    const register = (tagName)=>{
        if (customElements.get(tagName)) return Promise.resolve();
        return lazy_index_cjs_default()[tagName]?.();
    };
    const observer = new MutationObserver(async (mutations)=>{
        for (const { addedNodes } of mutations)for (const node of addedNodes)if (node.nodeType === Node.ELEMENT_NODE) await discover(node);
    });
    const initializeDiscovery = ()=>{
        for (const root of roots){
            discover(root);
            observer.observe(root, {
                subtree: true,
                childList: true
            });
        }
    };
    if ('loading' === document.readyState) document.addEventListener('DOMContentLoaded', initializeDiscovery);
    else initializeDiscovery();
}
exports.registerAutoloader = __webpack_exports__.registerAutoloader;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "registerAutoloader"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
