"use strict";
var __webpack_require__ = {};
(()=>{
    __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__, {
    enqueueOrDispatchInitializationEvent: ()=>enqueueOrDispatchInitializationEvent,
    isParentReady: ()=>isParentReady,
    markParentAsReady: ()=>markParentAsReady,
    queueEventForParent: ()=>queueEventForParent
});
function getWindow() {
    return window;
}
function getInitQueueNamespace() {
    if (!getWindow().initQueueNamespace) getWindow().initQueueNamespace = {
        eventQueueMap: new Map(),
        parentReadyMap: new Map()
    };
    return getWindow().initQueueNamespace;
}
function getEventQueueMap() {
    return getInitQueueNamespace().eventQueueMap;
}
function getParentReadyMap() {
    return getInitQueueNamespace().parentReadyMap;
}
function markParentAsReady(parent) {
    const parentReadyMap = getParentReadyMap();
    parentReadyMap.set(parent, true);
    const eventQueueMap = getEventQueueMap();
    const eventQueue = eventQueueMap.get(parent) || [];
    eventQueue.reverse();
    while(eventQueue.length > 0){
        const { event, element } = eventQueue.pop();
        element.dispatchEvent(event);
    }
    parent.dispatchEvent(new CustomEvent('atomic/parentReady', {
        bubbles: true
    }));
    eventQueueMap.delete(parent);
}
function isParentReady(parent) {
    const parentReadyMap = getParentReadyMap();
    return parentReadyMap.get(parent) || false;
}
function queueEventForParent(parent, event, element) {
    const eventQueueMap = getEventQueueMap();
    if (!eventQueueMap.has(parent)) eventQueueMap.set(parent, []);
    eventQueueMap.get(parent).push({
        event,
        element
    });
}
function enqueueOrDispatchInitializationEvent(parent, event, element) {
    if (isParentReady(parent)) element.dispatchEvent(event);
    else queueEventForParent(parent, event, element);
}
exports.enqueueOrDispatchInitializationEvent = __webpack_exports__.enqueueOrDispatchInitializationEvent;
exports.isParentReady = __webpack_exports__.isParentReady;
exports.markParentAsReady = __webpack_exports__.markParentAsReady;
exports.queueEventForParent = __webpack_exports__.queueEventForParent;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "enqueueOrDispatchInitializationEvent",
    "isParentReady",
    "markParentAsReady",
    "queueEventForParent"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
