// Clear the new API key from session after display
(function() {
    var keyDisplay = document.querySelector('.new-key-display');
    if (keyDisplay) {
        // Don't clear — let user see it. Clear on navigation.
        var csrfToken = (document.getElementById('data-api-keys') || {}).dataset.csrf || '';
        window.addEventListener('beforeunload', function() {
            fetch('/settings/api-keys/clear-new-key', {
                method: 'POST',
                headers: {'X-CSRF-Token': csrfToken}
            });
        });
    }
})();
