"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "useKeyNavigation", {
    enumerable: true,
    get: function() {
        return useKeyNavigation;
    }
});
var useKeyNavigation = function useKeyNavigation(param) {
    var isCalendarOpen = param.isCalendarOpen, closeOnEsc = param.closeOnEsc, format = param.format, maskWithFormat = param.maskWithFormat, delimiter = param.delimiter, onToggle = param.onToggle;
    var onKeyDown = function onKeyDown(event) {
        if (event.key === delimiter && maskWithFormat && format) {
            event.preventDefault();
            return;
        }
        if (event.code === 'Space' && !isCalendarOpen) {
            event.preventDefault();
            onToggle(true, event);
        }
        if (event.code === 'Escape' && isCalendarOpen && closeOnEsc) {
            event.preventDefault();
            onToggle(false, event);
        }
    };
    return {
        onKeyDown: onKeyDown
    };
};
