
        if (needsSessionId) {
            // Wait for DOM to be ready before showing modal
            if (document.readyState === 'loading') {
                document.addEventListener('DOMContentLoaded', function() {
                    showSessionModal();
                });
            } else {
                showSessionModal();
            }
        } else {
            // Session ID is already available, initialize immediately
            initializeWithSessionId();
        }
    </scri