const numberOnlyHandler = (e) => {
    var _a;
    const specialKeys = ['Backspace', 'Tab', 'Enter', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Delete'];
    // Check if the key is a special key
    if (e instanceof KeyboardEvent && specialKeys.includes(e.key)) {
        return;
    }
    // Allow Ctrl+V / Command+V for pasting
    const isPaste = e instanceof KeyboardEvent && (e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'v';
    if (isPaste) {
        return;
    }
    // Handle paste event
    if (e instanceof ClipboardEvent) {
        const clipboardData = (_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text');
        if (clipboardData && !/^\d+$/.test(clipboardData)) {
            e.preventDefault();
        }
        return;
    }
    // Prevent default action if the key is not a digit
    if (e instanceof KeyboardEvent && !/^\d$/.test(e.key)) {
        e.preventDefault();
    }
};

export { numberOnlyHandler as n };
