import common from '@iotize/common';
import common$1 from '@iotize/device-client.js/protocol/ble/common';

var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

function commonjsRequire () {
	throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs');
}

function unwrapExports (x) {
	return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

function createCommonjsModule(fn, module) {
	return module = { exports: {} }, fn(module, module.exports), module.exports;
}

function getCjsExportFromNamespace (n) {
	return n && n['default'] || n;
}

var mockPeripheral = createCommonjsModule(function (module, exports) {
"use strict";
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });


const common_3 = common$1;
class MockPeripheralAdapter {
    constructor(options = { state: 'connected', connectDelay: 100, disconnectDelay: 100 }) {
        this.options = options;
        this.services = {};
        this.services[common_3.BleConfig.services.lwm2m.service] = new MockServiceAdapter(common_3.BleConfig.services.lwm2m.service);
        this.services[common_3.BleConfig.services.fastLwm2m.service] = new MockServiceAdapter(common_3.BleConfig.services.lwm2m.service);
    }
    get state() {
        return this.options.state;
    }
    connect() {
        return __awaiter(this, void 0, void 0, function* () {
            yield common.sleep(this.options.connectDelay);
        });
    }
    disconnect() {
        return __awaiter(this, void 0, void 0, function* () {
            yield common.sleep(this.options.disconnectDelay);
        });
    }
    discoverServices() {
        return __awaiter(this, void 0, void 0, function* () {
            return this.services;
        });
    }
    getService(uuid) {
        return __awaiter(this, void 0, void 0, function* () {
            if (!(uuid in this.services)) {
                throw common$1.BleComError.serviceNotFound(uuid);
            }
            return this.services[uuid];
        });
    }
}
exports.MockPeripheralAdapter = MockPeripheralAdapter;
class MockServiceAdapter {
    constructor(uuid) {
        this.uuid = uuid;
    }
    getCharacteristic() {
        throw new Error(`Not implemented yet`);
    }
}
exports.MockServiceAdapter = MockServiceAdapter;

});

var mockPeripheral$1 = unwrapExports(mockPeripheral);
var mockPeripheral_1 = mockPeripheral.MockPeripheralAdapter;
var mockPeripheral_2 = mockPeripheral.MockServiceAdapter;

var public_api = createCommonjsModule(function (module, exports) {
"use strict";
function __export(m) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(mockPeripheral);

});

var public_api$1 = unwrapExports(public_api);

var iotizeDeviceClient_jsProtocolBleTesting = createCommonjsModule(function (module, exports) {
"use strict";
/**
 * Generated bundle index. Do not edit.
 */
function __export(m) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(public_api);

});

var iotizeDeviceClient_jsProtocolBleTesting$1 = unwrapExports(iotizeDeviceClient_jsProtocolBleTesting);

export default iotizeDeviceClient_jsProtocolBleTesting$1;
//# sourceMappingURL=iotize-device-client.js-protocol-ble-testing.js.map
