"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require("../../../../../Class/$");
const Functional_1 = require("../../../../../Class/Functional");
const _ids_1 = require("../../../../_ids");
class BluetoothDevice extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['opt'],
            o: ['device'],
        }, {
            output: {
                device: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_BLUETOOTH_DEVICE);
    }
    async f({ opt }, done) {
        const { api: { bluetooth: { requestDevice }, }, } = this.__system;
        let device;
        try {
            const _device = await requestDevice(opt);
            device = new (class _BluetoothDevice extends _1.$ {
                async getServer() {
                    return _device.getServer();
                }
            })(this.__system);
        }
        catch (err) {
            done(undefined, err.message);
            return;
        }
        done({ device });
    }
    d() { }
}
exports.default = BluetoothDevice;
//# sourceMappingURL=index.js.map