'selected')) {
                const index = selectedAudioDevices.indexOf(device);
                if (index !== -1) {
                    selectedAudioDevices.splice(index, 1);
                }
                element.classList.remove('selected');
            } else {
                selectedAudioDevices.push(device);
                element.classList.add('selected');
            }
        }

        function handleVideoSelection(element, device) {
            const prevSelected = element.par