import { Optional } from '@ephox/katamari';
import * as EditableFields from '../alien/EditableFields';
import * as Keys from '../alien/Keys';
import * as AlloyTriggers from '../api/events/AlloyTriggers';
import * as SystemEvents from '../api/events/SystemEvents';
import * as KeyMatch from '../navigation/KeyMatch';
const doDefaultExecute = (component, _simulatedEvent, focused) => {
    // Note, we use to pass through simulatedEvent here and make target: component. This simplification
    // may be a problem
    AlloyTriggers.dispatch(component, focused, SystemEvents.execute());
    return Optional.some(true);
};
const defaultExecute = (component, simulatedEvent, focused) => {
    const isComplex = EditableFields.inside(focused) && KeyMatch.inSet(Keys.SPACE)(simulatedEvent.event);
    return isComplex ? Optional.none() : doDefaultExecute(component, simulatedEvent, focused);
};
// On Firefox, pressing space fires a click event if the element maintains focus and fires a keyup. This
// stops the keyup, which should stop the click. We might want to make this only work for buttons and Firefox etc,
// but at this stage it's cleaner to just always do it. It makes sense that Keying that handles space should handle
// keyup also. This does make the name confusing, though.
const stopEventForFirefox = (_component, _simulatedEvent) => Optional.some(true);
export { defaultExecute, stopEventForFirefox };
//# sourceMappingURL=KeyingTypes.js.map