import { Arr } from '@ephox/katamari';
import { DomEvent } from '@ephox/sugar';
import * as AlloyEvents from '../../api/events/AlloyEvents';
const unbind = (bubblingState) => {
    Arr.each(bubblingState.get(), (unbinder) => {
        unbinder.unbind();
    });
};
const bind = (comp, bubblingConfig, bubblingState) => {
    const unbinders = Arr.map(bubblingConfig.events, (eventConfig) => DomEvent.bind(comp.element, eventConfig.native, (event) => {
        comp.getSystem().triggerEvent(eventConfig.simulated, comp.element, event);
    }));
    bubblingState.set(unbinders);
};
const events = (bubblingConfig, bubblingState) => AlloyEvents.derive([
    AlloyEvents.runOnAttached((comp) => bind(comp, bubblingConfig, bubblingState)),
    AlloyEvents.runOnDetached(() => unbind(bubblingState))
]);
export { events };
//# sourceMappingURL=ActiveAllowBubbling.js.map