"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__, {
    bindStateToController: ()=>bindStateToController
});
function bindStateToController(controllerProperty, options) {
    return (proto, stateProperty)=>{
        const ctor = proto.constructor;
        ctor.addInitializer((instance)=>{
            const component = instance;
            const { disconnectedCallback, initialize } = component;
            component.initialize = function() {
                initialize?.call(this);
                if (!initialize) return console.error(`ControllerState: The "initialize" method has to be defined and instantiate a controller for the property ${controllerProperty.toString()}`, component);
                if (!component[controllerProperty]) return console.error(`${controllerProperty.toString()} property is not defined on component`, component);
                if (options?.onUpdateCallbackMethod && !component[options.onUpdateCallbackMethod]) return console.error(`ControllerState: The onUpdateCallbackMethod property "${options.onUpdateCallbackMethod}" is not defined`, component);
                const controller = component[controllerProperty];
                const updateCallback = options?.onUpdateCallbackMethod ? component[options.onUpdateCallbackMethod] : void 0;
                const unsubscribeController = controller.subscribe(()=>{
                    component[stateProperty] = controller.state;
                    'function' == typeof updateCallback && updateCallback();
                });
                component.disconnectedCallback = ()=>{
                    component.isConnected || unsubscribeController?.();
                    disconnectedCallback?.call(component);
                };
            };
        });
    };
}
exports.bindStateToController = __webpack_exports__.bindStateToController;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "bindStateToController"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
