import QtQuick
import Quickshell.Services.Pipewire
import qs.config
import qs.services

Column {
    id: root

    property bool output: true
    readonly property var nodes: AudioDevices.nodes(root.output)
    readonly property var current: AudioDevices.current(root.output)

    width: parent ? parent.width : 620
    spacing: 8

    Repeater {
        model: root.nodes

        SoundDeviceRow {
            required property var modelData

            width: root.width
            node: modelData
            output: root.output
            selected: modelData === root.current
        }
    }

    Text {
        width: parent.width
        visible: root.nodes.length === 0
        text: Pipewire.ready ? "No audio devices found" : "Discovering audio devices…"
        color: Theme.fgDim
        font.family: Theme.fontFamily
        font.pixelSize: Theme.fontSize
        horizontalAlignment: Text.AlignHCenter
        topPadding: 18
        bottomPadding: 18
    }
}
