"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__, {
    buildCustomEvent: ()=>buildCustomEvent,
    eventPromise: ()=>eventPromise,
    listenOnce: ()=>listenOnce
});
const external_promise_utils_cjs_namespaceObject = require("./promise-utils.cjs");
function buildCustomEvent(name, detail) {
    return new CustomEvent(name, {
        detail,
        bubbles: true,
        cancelable: true,
        composed: true
    });
}
function listenOnce(element, type, listener, options) {
    const _listener = (evt)=>{
        element.removeEventListener(type, _listener, options);
        'object' == typeof listener ? listener.handleEvent.call(element, evt) : listener.call(element, evt);
    };
    element.addEventListener(type, _listener, options);
}
function eventPromise(element, type, timeoutMs = 0) {
    let promise = new Promise((resolve)=>{
        listenOnce(element, type, (e)=>{
            resolve(e);
        });
    });
    if (timeoutMs > 0) promise = (0, external_promise_utils_cjs_namespaceObject.promiseTimeout)(promise, timeoutMs);
    return promise;
}
exports.buildCustomEvent = __webpack_exports__.buildCustomEvent;
exports.eventPromise = __webpack_exports__.eventPromise;
exports.listenOnce = __webpack_exports__.listenOnce;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "buildCustomEvent",
    "eventPromise",
    "listenOnce"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
