"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__, {
    InitializeBindingsMixin: ()=>InitializeBindingsMixin
});
const initialization_common_utils_cjs_namespaceObject = require("../utils/initialization-common-utils.cjs");
function initializeBindings(instance) {
    return new Promise((resolve, reject)=>{
        instance.initialized = true;
        (0, initialization_common_utils_cjs_namespaceObject.fetchBindings)(instance).then((bindings)=>{
            instance.bindings = bindings;
            const updateLanguage = ()=>instance.requestUpdate();
            instance.bindings?.i18n?.on('languageChanged', updateLanguage);
            const unsubscribeLanguage = ()=>instance.bindings?.i18n?.off('languageChanged', updateLanguage);
            resolve(unsubscribeLanguage);
            instance.initialize?.();
        }).catch((error)=>{
            instance.error = error;
            reject(error);
        });
    });
}
class BindingController {
    hostConnected() {
        initializeBindings(this.host).then((unsubscribeLanguage)=>{
            this.unsubscribeLanguage = unsubscribeLanguage;
        }).catch((error)=>{
            this.host = error;
        });
    }
    hostDisconnected() {
        this.unsubscribeLanguage();
    }
    constructor(host){
        this.unsubscribeLanguage = ()=>{};
        this.host = host;
        this.host.addController(this);
    }
}
const InitializeBindingsMixin = (superClass)=>{
    class BindingControllerMixinClass extends superClass {
        initBindings() {
            new BindingController(this);
        }
        constructor(...args){
            super(...args);
            this.initBindings();
        }
    }
    return BindingControllerMixinClass;
};
exports.InitializeBindingsMixin = __webpack_exports__.InitializeBindingsMixin;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "InitializeBindingsMixin"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
