"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.listenToggle = exports.makeToggleListener = void 0;
function makeToggleListener(listener) {
    return (component) => {
        return listenToggle(component, (event, _event) => {
            listener(event, _event);
        });
    };
}
exports.makeToggleListener = makeToggleListener;
function listenToggle(component, onWheel) {
    const { $element } = component;
    const toggleListener = (_event) => {
        const { oldState, newState } = _event;
        if (newState !== oldState) {
            const shown = newState === 'open' ? true : false;
            onWheel(shown, _event);
        }
    };
    $element.addEventListener('toggle', toggleListener, { passive: false });
    return () => {
        $element.removeEventListener('toggle', toggleListener);
    };
}
exports.listenToggle = listenToggle;
//# sourceMappingURL=toggle.js.map