"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../../Class/Functional");
const _ids_1 = require("../../../../_ids");
class EnumerateDevices extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['any'],
            o: ['devices'],
        }, {}, system, _ids_1.ID_ENUMERATE_DEVICES);
    }
    async f({}, done) {
        const { api: { media: { enumerateDevices }, }, } = this.__system;
        let devices;
        try {
            devices = (await enumerateDevices()).map((d) => ({
                deviceId: d.deviceId,
                kind: d.kind,
                groupId: d.groupId,
                label: d.label,
            }));
        }
        catch (err) {
            done(undefined, err.message);
            return;
        }
        done({ devices });
    }
}
exports.default = EnumerateDevices;
//# sourceMappingURL=index.js.map