import { BalWindowResizeSubject } from "./window-resize.subject";
export function ListenToWindowResize() {
    return function (target, _propertyKey, _descriptor) {
        const { connectedCallback, disconnectedCallback } = target;
        target.connectedCallback = function () {
            if (!this._balWindowResizeSubject) {
                this._balWindowResizeSubject = new BalWindowResizeSubject();
                this._balWindowResizeSubject.attach(this);
            }
            return connectedCallback && connectedCallback.call(this);
        };
        target.disconnectedCallback = function () {
            if (this._balWindowResizeSubject) {
                this._balWindowResizeSubject.detach();
                this._balWindowResizeSubject = undefined;
            }
            return disconnectedCallback && disconnectedCallback.call(this);
        };
    };
}
