{{-- 安装向导：点击主按钮 / 提交表单时即时反馈「处理中」，防止重复点击 --}}
<style>
    @keyframes install-wizard-spin {
        to { transform: rotate(360deg); }
    }
    .btn.is-install-busy {
        opacity: 0.88 !important;
        pointer-events: none !important;
        cursor: wait !important;
    }
    .install-wizard-spinner {
        display: inline-block;
        width: 0.9375rem;
        height: 0.9375rem;
        margin-left: 0.35rem;
        vertical-align: -0.125rem;
        flex-shrink: 0;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.45);
        border-top-color: rgba(255, 255, 255, 0.95);
        animation: install-wizard-spin 0.65s linear infinite;
    }
    .btn.btn-secondary.is-install-busy .install-wizard-spinner,
    .btn.btn-muted.is-install-busy .install-wizard-spinner {
        border-color: rgba(37, 99, 235, 0.35);
        border-top-color: rgba(37, 99, 235, 0.9);
    }
</style>
<script>
    (function () {
        if (window.__dberpInstallWizardBusyBound) {
            return;
        }
        window.__dberpInstallWizardBusyBound = true;

        function appendSpinner(el) {
            if (el.querySelector('.install-wizard-spinner')) {
                return;
            }
            var sp = document.createElement('span');
            sp.className = 'install-wizard-spinner';
            sp.setAttribute('aria-hidden', 'true');
            el.appendChild(sp);
        }

        document.addEventListener('click', function (e) {
            var a = e.target.closest('a.btn[href]');
            if (!a) {
                return;
            }
            var href = (a.getAttribute('href') || '').trim();
            if (!href || href === '#' || href.toLowerCase().indexOf('javascript:') === 0) {
                return;
            }
            if (a.classList.contains('is-install-busy')) {
                e.preventDefault();

                return;
            }
            a.classList.add('is-install-busy');
            a.setAttribute('aria-busy', 'true');
            appendSpinner(a);
        });

        document.querySelectorAll('form').forEach(function (form) {
            form.addEventListener('submit', function () {
                var any = false;
                form.querySelectorAll('button[type="submit"], input[type="submit"]').forEach(function (btn) {
                    if (btn.disabled) {
                        return;
                    }
                    any = true;
                    btn.disabled = true;
                    btn.classList.add('is-install-busy');
                    btn.setAttribute('aria-busy', 'true');
                    appendSpinner(btn);
                });
                if (any) {
                    form.setAttribute('aria-busy', 'true');
                }
            });
        });
    })();
</script>
